documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995
  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. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. 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>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. 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;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. 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;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. 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;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * 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".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * 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"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * 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"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * 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)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * 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
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. 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;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * 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"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * 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".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * 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"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * 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".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * 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.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * 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)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @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
  5120. * @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
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. 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);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. 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>): InternalTexture;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. 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;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. 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;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. 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);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * 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;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * 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).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * 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).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * 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.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * 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.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * 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.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * 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.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * 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).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * 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).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * 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.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * 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.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * 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.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * 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.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * 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).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * 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).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * 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.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * 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.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * 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.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * 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.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * 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.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * 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.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * 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).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * 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).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * 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.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * 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.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * 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.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * 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.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: Nullable<AbstractActionManager>;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * 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
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @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
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @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
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @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
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @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
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. private _useInstancing;
  11027. /**
  11028. * An event triggered when the manager is disposed.
  11029. */
  11030. onDisposeObservable: Observable<SpriteManager>;
  11031. private _onDisposeObserver;
  11032. /**
  11033. * Callback called when the manager is disposed
  11034. */
  11035. set onDispose(callback: () => void);
  11036. private _capacity;
  11037. private _fromPacked;
  11038. private _spriteTexture;
  11039. private _epsilon;
  11040. private _scene;
  11041. private _vertexData;
  11042. private _buffer;
  11043. private _vertexBuffers;
  11044. private _spriteBuffer;
  11045. private _indexBuffer;
  11046. private _effectBase;
  11047. private _effectFog;
  11048. private _vertexBufferSize;
  11049. /**
  11050. * Gets or sets the unique id of the sprite
  11051. */
  11052. uniqueId: number;
  11053. /**
  11054. * Gets the array of sprites
  11055. */
  11056. get children(): Sprite[];
  11057. /**
  11058. * Gets the hosting scene
  11059. */
  11060. get scene(): Scene;
  11061. /**
  11062. * Gets the capacity of the manager
  11063. */
  11064. get capacity(): number;
  11065. /**
  11066. * Gets or sets the spritesheet texture
  11067. */
  11068. get texture(): Texture;
  11069. set texture(value: Texture);
  11070. private _blendMode;
  11071. /**
  11072. * Blend mode use to render the particle, it can be any of
  11073. * the static Constants.ALPHA_x properties provided in this class.
  11074. * Default value is Constants.ALPHA_COMBINE
  11075. */
  11076. get blendMode(): number;
  11077. set blendMode(blendMode: number);
  11078. /** Disables writing to the depth buffer when rendering the sprites.
  11079. * It can be handy to disable depth writing when using textures without alpha channel
  11080. * and setting some specific blend modes.
  11081. */
  11082. disableDepthWrite: boolean;
  11083. /**
  11084. * Creates a new sprite manager
  11085. * @param name defines the manager's name
  11086. * @param imgUrl defines the sprite sheet url
  11087. * @param capacity defines the maximum allowed number of sprites
  11088. * @param cellSize defines the size of a sprite cell
  11089. * @param scene defines the hosting scene
  11090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11091. * @param samplingMode defines the smapling mode to use with spritesheet
  11092. * @param fromPacked set to false; do not alter
  11093. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11094. */
  11095. constructor(
  11096. /** defines the manager's name */
  11097. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11098. /**
  11099. * Returns the string "SpriteManager"
  11100. * @returns "SpriteManager"
  11101. */
  11102. getClassName(): string;
  11103. private _makePacked;
  11104. private _appendSpriteVertex;
  11105. private _checkTextureAlpha;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11112. * @returns null if no hit or a PickingInfo
  11113. */
  11114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11115. /**
  11116. * Intersects the sprites with a ray
  11117. * @param ray defines the ray to intersect with
  11118. * @param camera defines the current active camera
  11119. * @param predicate defines a predicate used to select candidate sprites
  11120. * @returns null if no hit or a PickingInfo array
  11121. */
  11122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11123. /**
  11124. * Render all child sprites
  11125. */
  11126. render(): void;
  11127. /**
  11128. * Release associated resources
  11129. */
  11130. dispose(): void;
  11131. /**
  11132. * Serializes the sprite manager to a JSON object
  11133. * @param serializeTexture defines if the texture must be serialized as well
  11134. * @returns the JSON object
  11135. */
  11136. serialize(serializeTexture?: boolean): any;
  11137. /**
  11138. * Parses a JSON object to create a new sprite manager.
  11139. * @param parsedManager The JSON object to parse
  11140. * @param scene The scene to create the sprite managerin
  11141. * @param rootUrl The root url to use to load external dependencies like texture
  11142. * @returns the new sprite manager
  11143. */
  11144. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11145. /**
  11146. * Creates a sprite manager from a snippet saved in a remote file
  11147. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11148. * @param url defines the url to load from
  11149. * @param scene defines the hosting scene
  11150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11151. * @returns a promise that will resolve to the new sprite manager
  11152. */
  11153. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11154. /**
  11155. * Creates a sprite manager from a snippet saved by the sprite editor
  11156. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11157. * @param scene defines the hosting scene
  11158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11159. * @returns a promise that will resolve to the new sprite manager
  11160. */
  11161. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. /** Interface used by value gradients (color, factor, ...) */
  11166. export interface IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. }
  11172. /** Class used to store color4 gradient */
  11173. export class ColorGradient implements IValueGradient {
  11174. /**
  11175. * Gets or sets the gradient value (between 0 and 1)
  11176. */
  11177. gradient: number;
  11178. /**
  11179. * Gets or sets first associated color
  11180. */
  11181. color1: Color4;
  11182. /**
  11183. * Gets or sets second associated color
  11184. */
  11185. color2?: Color4 | undefined;
  11186. /**
  11187. * Creates a new color4 gradient
  11188. * @param gradient gets or sets the gradient value (between 0 and 1)
  11189. * @param color1 gets or sets first associated color
  11190. * @param color2 gets or sets first second color
  11191. */
  11192. constructor(
  11193. /**
  11194. * Gets or sets the gradient value (between 0 and 1)
  11195. */
  11196. gradient: number,
  11197. /**
  11198. * Gets or sets first associated color
  11199. */
  11200. color1: Color4,
  11201. /**
  11202. * Gets or sets second associated color
  11203. */
  11204. color2?: Color4 | undefined);
  11205. /**
  11206. * Will get a color picked randomly between color1 and color2.
  11207. * If color2 is undefined then color1 will be used
  11208. * @param result defines the target Color4 to store the result in
  11209. */
  11210. getColorToRef(result: Color4): void;
  11211. }
  11212. /** Class used to store color 3 gradient */
  11213. export class Color3Gradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets the associated color
  11220. */
  11221. color: Color3;
  11222. /**
  11223. * Creates a new color3 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color gets or sets associated color
  11226. */
  11227. constructor(
  11228. /**
  11229. * Gets or sets the gradient value (between 0 and 1)
  11230. */
  11231. gradient: number,
  11232. /**
  11233. * Gets or sets the associated color
  11234. */
  11235. color: Color3);
  11236. }
  11237. /** Class used to store factor gradient */
  11238. export class FactorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated factor
  11245. */
  11246. factor1: number;
  11247. /**
  11248. * Gets or sets second associated factor
  11249. */
  11250. factor2?: number | undefined;
  11251. /**
  11252. * Creates a new factor gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param factor1 gets or sets first associated factor
  11255. * @param factor2 gets or sets second associated factor
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated factor
  11264. */
  11265. factor1: number,
  11266. /**
  11267. * Gets or sets second associated factor
  11268. */
  11269. factor2?: number | undefined);
  11270. /**
  11271. * Will get a number picked randomly between factor1 and factor2.
  11272. * If factor2 is undefined then factor1 will be used
  11273. * @returns the picked number
  11274. */
  11275. getFactor(): number;
  11276. }
  11277. /**
  11278. * Helper used to simplify some generic gradient tasks
  11279. */
  11280. export class GradientHelper {
  11281. /**
  11282. * Gets the current gradient from an array of IValueGradient
  11283. * @param ratio defines the current ratio to get
  11284. * @param gradients defines the array of IValueGradient
  11285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11286. */
  11287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11288. }
  11289. }
  11290. declare module BABYLON {
  11291. interface ThinEngine {
  11292. /**
  11293. * Creates a raw texture
  11294. * @param data defines the data to store in the texture
  11295. * @param width defines the width of the texture
  11296. * @param height defines the height of the texture
  11297. * @param format defines the format of the data
  11298. * @param generateMipMaps defines if the engine should generate the mip levels
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. * @returns the raw texture inside an InternalTexture
  11304. */
  11305. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11306. /**
  11307. * Update a raw texture
  11308. * @param texture defines the texture to update
  11309. * @param data defines the data to store in the texture
  11310. * @param format defines the format of the data
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. */
  11313. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11314. /**
  11315. * Update a raw texture
  11316. * @param texture defines the texture to update
  11317. * @param data defines the data to store in the texture
  11318. * @param format defines the format of the data
  11319. * @param invertY defines if data must be stored with Y axis inverted
  11320. * @param compression defines the compression used (null by default)
  11321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11322. */
  11323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11324. /**
  11325. * Creates a new raw cube texture
  11326. * @param data defines the array of data to use to create each face
  11327. * @param size defines the size of the textures
  11328. * @param format defines the format of the data
  11329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11330. * @param generateMipMaps defines if the engine should generate the mip levels
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11333. * @param compression defines the compression used (null by default)
  11334. * @returns the cube texture as an InternalTexture
  11335. */
  11336. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. */
  11345. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11346. /**
  11347. * Update a raw cube texture
  11348. * @param texture defines the texture to udpdate
  11349. * @param data defines the data to store
  11350. * @param format defines the data format
  11351. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the compression used (null by default)
  11354. */
  11355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11356. /**
  11357. * Update a raw cube texture
  11358. * @param texture defines the texture to udpdate
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. * @param invertY defines if data must be stored with Y axis inverted
  11363. * @param compression defines the compression used (null by default)
  11364. * @param level defines which level of the texture to update
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11367. /**
  11368. * Creates a new raw cube texture from a specified url
  11369. * @param url defines the url where the data is located
  11370. * @param scene defines the current scene
  11371. * @param size defines the size of the textures
  11372. * @param format defines the format of the data
  11373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11374. * @param noMipmap defines if the engine should avoid generating the mip levels
  11375. * @param callback defines a callback used to extract texture data from loaded data
  11376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11377. * @param onLoad defines a callback called when texture is loaded
  11378. * @param onError defines a callback called if there is an error
  11379. * @returns the cube texture as an InternalTexture
  11380. */
  11381. 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;
  11382. /**
  11383. * Creates a new raw cube texture from a specified url
  11384. * @param url defines the url where the data is located
  11385. * @param scene defines the current scene
  11386. * @param size defines the size of the textures
  11387. * @param format defines the format of the data
  11388. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11389. * @param noMipmap defines if the engine should avoid generating the mip levels
  11390. * @param callback defines a callback used to extract texture data from loaded data
  11391. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11392. * @param onLoad defines a callback called when texture is loaded
  11393. * @param onError defines a callback called if there is an error
  11394. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11395. * @param invertY defines if data must be stored with Y axis inverted
  11396. * @returns the cube texture as an InternalTexture
  11397. */
  11398. 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;
  11399. /**
  11400. * Creates a new raw 3D texture
  11401. * @param data defines the data used to create the texture
  11402. * @param width defines the width of the texture
  11403. * @param height defines the height of the texture
  11404. * @param depth defines the depth of the texture
  11405. * @param format defines the format of the texture
  11406. * @param generateMipMaps defines if the engine must generate mip levels
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11409. * @param compression defines the compressed used (can be null)
  11410. * @param textureType defines the compressed used (can be null)
  11411. * @returns a new raw 3D texture (stored in an InternalTexture)
  11412. */
  11413. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11414. /**
  11415. * Update a raw 3D texture
  11416. * @param texture defines the texture to update
  11417. * @param data defines the data to store
  11418. * @param format defines the data format
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. */
  11421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11422. /**
  11423. * Update a raw 3D texture
  11424. * @param texture defines the texture to update
  11425. * @param data defines the data to store
  11426. * @param format defines the data format
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the used compression (can be null)
  11429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11430. */
  11431. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11432. /**
  11433. * Creates a new raw 2D array texture
  11434. * @param data defines the data used to create the texture
  11435. * @param width defines the width of the texture
  11436. * @param height defines the height of the texture
  11437. * @param depth defines the number of layers of the texture
  11438. * @param format defines the format of the texture
  11439. * @param generateMipMaps defines if the engine must generate mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11442. * @param compression defines the compressed used (can be null)
  11443. * @param textureType defines the compressed used (can be null)
  11444. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11445. */
  11446. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11447. /**
  11448. * Update a raw 2D array texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store
  11451. * @param format defines the data format
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw 2D array texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store
  11459. * @param format defines the data format
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the used compression (can be null)
  11462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11463. */
  11464. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * Raw texture can help creating a texture directly from an array of data.
  11470. * This can be super useful if you either get the data from an uncompressed source or
  11471. * if you wish to create your texture pixel by pixel.
  11472. */
  11473. export class RawTexture extends Texture {
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number;
  11478. /**
  11479. * Instantiates a new RawTexture.
  11480. * Raw texture can help creating a texture directly from an array of data.
  11481. * This can be super useful if you either get the data from an uncompressed source or
  11482. * if you wish to create your texture pixel by pixel.
  11483. * @param data define the array of data to use to create the texture
  11484. * @param width define the width of the texture
  11485. * @param height define the height of the texture
  11486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11487. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11488. * @param generateMipMaps define whether mip maps should be generated or not
  11489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11492. */
  11493. constructor(data: ArrayBufferView, width: number, height: number,
  11494. /**
  11495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11496. */
  11497. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11498. /**
  11499. * Updates the texture underlying data.
  11500. * @param data Define the new data of the texture
  11501. */
  11502. update(data: ArrayBufferView): void;
  11503. /**
  11504. * Creates a luminance texture from some data.
  11505. * @param data Define the texture data
  11506. * @param width Define the width of the texture
  11507. * @param height Define the height of the texture
  11508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @returns the luminance texture
  11513. */
  11514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11515. /**
  11516. * Creates a luminance alpha texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance alpha texture
  11525. */
  11526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates an alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the alpha texture
  11537. */
  11538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates a RGB texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11549. * @returns the RGB alpha texture
  11550. */
  11551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11552. /**
  11553. * Creates a RGBA texture from some data.
  11554. * @param data Define the texture data
  11555. * @param width Define the width of the texture
  11556. * @param height Define the height of the texture
  11557. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11562. * @returns the RGBA texture
  11563. */
  11564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11565. /**
  11566. * Creates a R texture from some data.
  11567. * @param data Define the texture data
  11568. * @param width Define the width of the texture
  11569. * @param height Define the height of the texture
  11570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11575. * @returns the R texture
  11576. */
  11577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. interface ThinEngine {
  11582. /**
  11583. * Update a dynamic index buffer
  11584. * @param indexBuffer defines the target index buffer
  11585. * @param indices defines the data to update
  11586. * @param offset defines the offset in the target index buffer where update should start
  11587. */
  11588. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11589. /**
  11590. * Updates a dynamic vertex buffer.
  11591. * @param vertexBuffer the vertex buffer to update
  11592. * @param data the data used to update the vertex buffer
  11593. * @param byteOffset the byte offset of the data
  11594. * @param byteLength the byte length of the data
  11595. */
  11596. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. interface AbstractScene {
  11601. /**
  11602. * The list of procedural textures added to the scene
  11603. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11604. */
  11605. proceduralTextures: Array<ProceduralTexture>;
  11606. }
  11607. /**
  11608. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11609. * in a given scene.
  11610. */
  11611. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /**
  11621. * Creates a new instance of the component for the given scene
  11622. * @param scene Defines the scene to register the component in
  11623. */
  11624. constructor(scene: Scene);
  11625. /**
  11626. * Registers the component in a given scene
  11627. */
  11628. register(): void;
  11629. /**
  11630. * Rebuilds the elements related to this component in case of
  11631. * context lost for instance.
  11632. */
  11633. rebuild(): void;
  11634. /**
  11635. * Disposes the component and the associated ressources.
  11636. */
  11637. dispose(): void;
  11638. private _beforeClear;
  11639. }
  11640. }
  11641. declare module BABYLON {
  11642. interface ThinEngine {
  11643. /**
  11644. * Creates a new render target cube texture
  11645. * @param size defines the size of the texture
  11646. * @param options defines the options used to create the texture
  11647. * @returns a new render target cube texture stored in an InternalTexture
  11648. */
  11649. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var proceduralVertexShader: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /**
  11661. * 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.
  11662. * This is the base class of any Procedural texture and contains most of the shareable code.
  11663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11664. */
  11665. export class ProceduralTexture extends Texture {
  11666. /**
  11667. * Define if the texture is enabled or not (disabled texture will not render)
  11668. */
  11669. isEnabled: boolean;
  11670. /**
  11671. * Define if the texture must be cleared before rendering (default is true)
  11672. */
  11673. autoClear: boolean;
  11674. /**
  11675. * Callback called when the texture is generated
  11676. */
  11677. onGenerated: () => void;
  11678. /**
  11679. * Event raised when the texture is generated
  11680. */
  11681. onGeneratedObservable: Observable<ProceduralTexture>;
  11682. /** @hidden */
  11683. _generateMipMaps: boolean;
  11684. /** @hidden **/
  11685. _effect: Effect;
  11686. /** @hidden */
  11687. _textures: {
  11688. [key: string]: Texture;
  11689. };
  11690. /** @hidden */
  11691. protected _fallbackTexture: Nullable<Texture>;
  11692. private _size;
  11693. private _currentRefreshId;
  11694. private _frameId;
  11695. private _refreshRate;
  11696. private _vertexBuffers;
  11697. private _indexBuffer;
  11698. private _uniforms;
  11699. private _samplers;
  11700. private _fragment;
  11701. private _floats;
  11702. private _ints;
  11703. private _floatsArrays;
  11704. private _colors3;
  11705. private _colors4;
  11706. private _vectors2;
  11707. private _vectors3;
  11708. private _matrices;
  11709. private _fallbackTextureUsed;
  11710. private _fullEngine;
  11711. private _cachedDefines;
  11712. private _contentUpdateId;
  11713. private _contentData;
  11714. /**
  11715. * Instantiates a new procedural texture.
  11716. * 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.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. * @param name Define the name of the texture
  11720. * @param size Define the size of the texture to create
  11721. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11722. * @param scene Define the scene the texture belongs to
  11723. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11724. * @param generateMipMaps Define if the texture should creates mip maps or not
  11725. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11726. */
  11727. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11728. /**
  11729. * The effect that is created when initializing the post process.
  11730. * @returns The created effect corresponding the the postprocess.
  11731. */
  11732. getEffect(): Effect;
  11733. /**
  11734. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11735. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11736. */
  11737. getContent(): Nullable<ArrayBufferView>;
  11738. private _createIndexBuffer;
  11739. /** @hidden */
  11740. _rebuild(): void;
  11741. /**
  11742. * Resets the texture in order to recreate its associated resources.
  11743. * This can be called in case of context loss
  11744. */
  11745. reset(): void;
  11746. protected _getDefines(): string;
  11747. /**
  11748. * Is the texture ready to be used ? (rendered at least once)
  11749. * @returns true if ready, otherwise, false.
  11750. */
  11751. isReady(): boolean;
  11752. /**
  11753. * Resets the refresh counter of the texture and start bak from scratch.
  11754. * Could be useful to regenerate the texture if it is setup to render only once.
  11755. */
  11756. resetRefreshCounter(): void;
  11757. /**
  11758. * Set the fragment shader to use in order to render the texture.
  11759. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11760. */
  11761. setFragment(fragment: any): void;
  11762. /**
  11763. * Define the refresh rate of the texture or the rendering frequency.
  11764. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11765. */
  11766. get refreshRate(): number;
  11767. set refreshRate(value: number);
  11768. /** @hidden */
  11769. _shouldRender(): boolean;
  11770. /**
  11771. * Get the size the texture is rendering at.
  11772. * @returns the size (texture is always squared)
  11773. */
  11774. getRenderSize(): number;
  11775. /**
  11776. * Resize the texture to new value.
  11777. * @param size Define the new size the texture should have
  11778. * @param generateMipMaps Define whether the new texture should create mip maps
  11779. */
  11780. resize(size: number, generateMipMaps: boolean): void;
  11781. private _checkUniform;
  11782. /**
  11783. * Set a texture in the shader program used to render.
  11784. * @param name Define the name of the uniform samplers as defined in the shader
  11785. * @param texture Define the texture to bind to this sampler
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setTexture(name: string, texture: Texture): ProceduralTexture;
  11789. /**
  11790. * Set a float in the shader.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setFloat(name: string, value: number): ProceduralTexture;
  11796. /**
  11797. * Set a int in the shader.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setInt(name: string, value: number): ProceduralTexture;
  11803. /**
  11804. * Set an array of floats in the shader.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setFloats(name: string, value: number[]): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Color3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setColor3(name: string, value: Color3): ProceduralTexture;
  11817. /**
  11818. * Set a vec4 in the shader from a Color4.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setColor4(name: string, value: Color4): ProceduralTexture;
  11824. /**
  11825. * Set a vec2 in the shader from a Vector2.
  11826. * @param name Define the name of the uniform as defined in the shader
  11827. * @param value Define the value to give to the uniform
  11828. * @return the texture itself allowing "fluent" like uniform updates
  11829. */
  11830. setVector2(name: string, value: Vector2): ProceduralTexture;
  11831. /**
  11832. * Set a vec3 in the shader from a Vector3.
  11833. * @param name Define the name of the uniform as defined in the shader
  11834. * @param value Define the value to give to the uniform
  11835. * @return the texture itself allowing "fluent" like uniform updates
  11836. */
  11837. setVector3(name: string, value: Vector3): ProceduralTexture;
  11838. /**
  11839. * Set a mat4 in the shader from a MAtrix.
  11840. * @param name Define the name of the uniform as defined in the shader
  11841. * @param value Define the value to give to the uniform
  11842. * @return the texture itself allowing "fluent" like uniform updates
  11843. */
  11844. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11845. /**
  11846. * Render the texture to its associated render target.
  11847. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11848. */
  11849. render(useCameraPostProcess?: boolean): void;
  11850. /**
  11851. * Clone the texture.
  11852. * @returns the cloned texture
  11853. */
  11854. clone(): ProceduralTexture;
  11855. /**
  11856. * Dispose the texture and release its asoociated resources.
  11857. */
  11858. dispose(): void;
  11859. }
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * This represents the base class for particle system in Babylon.
  11864. * 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.
  11865. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11866. * @example https://doc.babylonjs.com/babylon101/particles
  11867. */
  11868. export class BaseParticleSystem {
  11869. /**
  11870. * Source color is added to the destination color without alpha affecting the result
  11871. */
  11872. static BLENDMODE_ONEONE: number;
  11873. /**
  11874. * Blend current color and particle color using particle’s alpha
  11875. */
  11876. static BLENDMODE_STANDARD: number;
  11877. /**
  11878. * Add current color and particle color multiplied by particle’s alpha
  11879. */
  11880. static BLENDMODE_ADD: number;
  11881. /**
  11882. * Multiply current color with particle color
  11883. */
  11884. static BLENDMODE_MULTIPLY: number;
  11885. /**
  11886. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11887. */
  11888. static BLENDMODE_MULTIPLYADD: number;
  11889. /**
  11890. * List of animations used by the particle system.
  11891. */
  11892. animations: Animation[];
  11893. /**
  11894. * Gets or sets the unique id of the particle system
  11895. */
  11896. uniqueId: number;
  11897. /**
  11898. * The id of the Particle system.
  11899. */
  11900. id: string;
  11901. /**
  11902. * The friendly name of the Particle system.
  11903. */
  11904. name: string;
  11905. /**
  11906. * Snippet ID if the particle system was created from the snippet server
  11907. */
  11908. snippetId: string;
  11909. /**
  11910. * The rendering group used by the Particle system to chose when to render.
  11911. */
  11912. renderingGroupId: number;
  11913. /**
  11914. * The emitter represents the Mesh or position we are attaching the particle system to.
  11915. */
  11916. emitter: Nullable<AbstractMesh | Vector3>;
  11917. /**
  11918. * The maximum number of particles to emit per frame
  11919. */
  11920. emitRate: number;
  11921. /**
  11922. * If you want to launch only a few particles at once, that can be done, as well.
  11923. */
  11924. manualEmitCount: number;
  11925. /**
  11926. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11927. */
  11928. updateSpeed: number;
  11929. /**
  11930. * The amount of time the particle system is running (depends of the overall update speed).
  11931. */
  11932. targetStopDuration: number;
  11933. /**
  11934. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11935. */
  11936. disposeOnStop: boolean;
  11937. /**
  11938. * Minimum power of emitting particles.
  11939. */
  11940. minEmitPower: number;
  11941. /**
  11942. * Maximum power of emitting particles.
  11943. */
  11944. maxEmitPower: number;
  11945. /**
  11946. * Minimum life time of emitting particles.
  11947. */
  11948. minLifeTime: number;
  11949. /**
  11950. * Maximum life time of emitting particles.
  11951. */
  11952. maxLifeTime: number;
  11953. /**
  11954. * Minimum Size of emitting particles.
  11955. */
  11956. minSize: number;
  11957. /**
  11958. * Maximum Size of emitting particles.
  11959. */
  11960. maxSize: number;
  11961. /**
  11962. * Minimum scale of emitting particles on X axis.
  11963. */
  11964. minScaleX: number;
  11965. /**
  11966. * Maximum scale of emitting particles on X axis.
  11967. */
  11968. maxScaleX: number;
  11969. /**
  11970. * Minimum scale of emitting particles on Y axis.
  11971. */
  11972. minScaleY: number;
  11973. /**
  11974. * Maximum scale of emitting particles on Y axis.
  11975. */
  11976. maxScaleY: number;
  11977. /**
  11978. * Gets or sets the minimal initial rotation in radians.
  11979. */
  11980. minInitialRotation: number;
  11981. /**
  11982. * Gets or sets the maximal initial rotation in radians.
  11983. */
  11984. maxInitialRotation: number;
  11985. /**
  11986. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11987. */
  11988. minAngularSpeed: number;
  11989. /**
  11990. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11991. */
  11992. maxAngularSpeed: number;
  11993. /**
  11994. * The texture used to render each particle. (this can be a spritesheet)
  11995. */
  11996. particleTexture: Nullable<BaseTexture>;
  11997. /**
  11998. * The layer mask we are rendering the particles through.
  11999. */
  12000. layerMask: number;
  12001. /**
  12002. * This can help using your own shader to render the particle system.
  12003. * The according effect will be created
  12004. */
  12005. customShader: any;
  12006. /**
  12007. * By default particle system starts as soon as they are created. This prevents the
  12008. * automatic start to happen and let you decide when to start emitting particles.
  12009. */
  12010. preventAutoStart: boolean;
  12011. private _noiseTexture;
  12012. /**
  12013. * Gets or sets a texture used to add random noise to particle positions
  12014. */
  12015. get noiseTexture(): Nullable<ProceduralTexture>;
  12016. set noiseTexture(value: Nullable<ProceduralTexture>);
  12017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12018. noiseStrength: Vector3;
  12019. /**
  12020. * Callback triggered when the particle animation is ending.
  12021. */
  12022. onAnimationEnd: Nullable<() => void>;
  12023. /**
  12024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12025. */
  12026. blendMode: number;
  12027. /**
  12028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12029. * to override the particles.
  12030. */
  12031. forceDepthWrite: boolean;
  12032. /** 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 */
  12033. preWarmCycles: number;
  12034. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12035. preWarmStepOffset: number;
  12036. /**
  12037. * 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)
  12038. */
  12039. spriteCellChangeSpeed: number;
  12040. /**
  12041. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12042. */
  12043. startSpriteCellID: number;
  12044. /**
  12045. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12046. */
  12047. endSpriteCellID: number;
  12048. /**
  12049. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12050. */
  12051. spriteCellWidth: number;
  12052. /**
  12053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12054. */
  12055. spriteCellHeight: number;
  12056. /**
  12057. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12058. */
  12059. spriteRandomStartCell: boolean;
  12060. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12061. translationPivot: Vector2;
  12062. /** @hidden */
  12063. protected _isAnimationSheetEnabled: boolean;
  12064. /**
  12065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12066. */
  12067. beginAnimationOnStart: boolean;
  12068. /**
  12069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12070. */
  12071. beginAnimationFrom: number;
  12072. /**
  12073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12074. */
  12075. beginAnimationTo: number;
  12076. /**
  12077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12078. */
  12079. beginAnimationLoop: boolean;
  12080. /**
  12081. * Gets or sets a world offset applied to all particles
  12082. */
  12083. worldOffset: Vector3;
  12084. /**
  12085. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12086. */
  12087. get isAnimationSheetEnabled(): boolean;
  12088. set isAnimationSheetEnabled(value: boolean);
  12089. /**
  12090. * Get hosting scene
  12091. * @returns the scene
  12092. */
  12093. getScene(): Nullable<Scene>;
  12094. /**
  12095. * You can use gravity if you want to give an orientation to your particles.
  12096. */
  12097. gravity: Vector3;
  12098. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12099. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12100. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12102. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12103. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12105. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12106. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12107. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12108. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12109. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12111. /**
  12112. * Defines the delay in milliseconds before starting the system (0 by default)
  12113. */
  12114. startDelay: number;
  12115. /**
  12116. * Gets the current list of drag gradients.
  12117. * You must use addDragGradient and removeDragGradient to udpate this list
  12118. * @returns the list of drag gradients
  12119. */
  12120. getDragGradients(): Nullable<Array<FactorGradient>>;
  12121. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12122. limitVelocityDamping: number;
  12123. /**
  12124. * Gets the current list of limit velocity gradients.
  12125. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12126. * @returns the list of limit velocity gradients
  12127. */
  12128. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12129. /**
  12130. * Gets the current list of color gradients.
  12131. * You must use addColorGradient and removeColorGradient to udpate this list
  12132. * @returns the list of color gradients
  12133. */
  12134. getColorGradients(): Nullable<Array<ColorGradient>>;
  12135. /**
  12136. * Gets the current list of size gradients.
  12137. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12138. * @returns the list of size gradients
  12139. */
  12140. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of color remap gradients.
  12143. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12144. * @returns the list of color remap gradients
  12145. */
  12146. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of alpha remap gradients.
  12149. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12150. * @returns the list of alpha remap gradients
  12151. */
  12152. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of life time gradients.
  12155. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12156. * @returns the list of life time gradients
  12157. */
  12158. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of angular speed gradients.
  12161. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12162. * @returns the list of angular speed gradients
  12163. */
  12164. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of velocity gradients.
  12167. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12168. * @returns the list of velocity gradients
  12169. */
  12170. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of start size gradients.
  12173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12174. * @returns the list of start size gradients
  12175. */
  12176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Gets the current list of emit rate gradients.
  12179. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12180. * @returns the list of emit rate gradients
  12181. */
  12182. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction1(): Vector3;
  12188. set direction1(value: Vector3);
  12189. /**
  12190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get direction2(): Vector3;
  12194. set direction2(value: Vector3);
  12195. /**
  12196. * 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.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get minEmitBox(): Vector3;
  12200. set minEmitBox(value: Vector3);
  12201. /**
  12202. * 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.
  12203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12204. */
  12205. get maxEmitBox(): Vector3;
  12206. set maxEmitBox(value: Vector3);
  12207. /**
  12208. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12209. */
  12210. color1: Color4;
  12211. /**
  12212. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12213. */
  12214. color2: Color4;
  12215. /**
  12216. * Color the particle will have at the end of its lifetime
  12217. */
  12218. colorDead: Color4;
  12219. /**
  12220. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12221. */
  12222. textureMask: Color4;
  12223. /**
  12224. * The particle emitter type defines the emitter used by the particle system.
  12225. * It can be for example box, sphere, or cone...
  12226. */
  12227. particleEmitterType: IParticleEmitterType;
  12228. /** @hidden */
  12229. _isSubEmitter: boolean;
  12230. /**
  12231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12233. */
  12234. billboardMode: number;
  12235. protected _isBillboardBased: boolean;
  12236. /**
  12237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12238. */
  12239. get isBillboardBased(): boolean;
  12240. set isBillboardBased(value: boolean);
  12241. /**
  12242. * The scene the particle system belongs to.
  12243. */
  12244. protected _scene: Nullable<Scene>;
  12245. /**
  12246. * The engine the particle system belongs to.
  12247. */
  12248. protected _engine: ThinEngine;
  12249. /**
  12250. * Local cache of defines for image processing.
  12251. */
  12252. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12253. /**
  12254. * Default configuration related to image processing available in the standard Material.
  12255. */
  12256. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12257. /**
  12258. * Gets the image processing configuration used either in this material.
  12259. */
  12260. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12261. /**
  12262. * Sets the Default image processing configuration used either in the this material.
  12263. *
  12264. * If sets to null, the scene one is in use.
  12265. */
  12266. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12267. /**
  12268. * Attaches a new image processing configuration to the Standard Material.
  12269. * @param configuration
  12270. */
  12271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12272. /** @hidden */
  12273. protected _reset(): void;
  12274. /** @hidden */
  12275. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12276. /**
  12277. * Instantiates a particle system.
  12278. * 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.
  12279. * @param name The name of the particle system
  12280. */
  12281. constructor(name: string);
  12282. /**
  12283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @returns the emitter
  12287. */
  12288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12289. /**
  12290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12291. * @param radius The radius of the hemisphere to emit from
  12292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12293. * @returns the emitter
  12294. */
  12295. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12296. /**
  12297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12298. * @param radius The radius of the sphere to emit from
  12299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12300. * @returns the emitter
  12301. */
  12302. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12303. /**
  12304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12305. * @param radius The radius of the sphere to emit from
  12306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @returns the emitter
  12309. */
  12310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12311. /**
  12312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12313. * @param radius The radius of the emission cylinder
  12314. * @param height The height of the emission cylinder
  12315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12317. * @returns the emitter
  12318. */
  12319. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12320. /**
  12321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12322. * @param radius The radius of the cylinder to emit from
  12323. * @param height The height of the emission cylinder
  12324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @returns the emitter
  12328. */
  12329. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12330. /**
  12331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12332. * @param radius The radius of the cone to emit from
  12333. * @param angle The base angle of the cone
  12334. * @returns the emitter
  12335. */
  12336. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12337. /**
  12338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @returns the emitter
  12344. */
  12345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12346. }
  12347. }
  12348. declare module BABYLON {
  12349. /**
  12350. * Type of sub emitter
  12351. */
  12352. export enum SubEmitterType {
  12353. /**
  12354. * Attached to the particle over it's lifetime
  12355. */
  12356. ATTACHED = 0,
  12357. /**
  12358. * Created when the particle dies
  12359. */
  12360. END = 1
  12361. }
  12362. /**
  12363. * Sub emitter class used to emit particles from an existing particle
  12364. */
  12365. export class SubEmitter {
  12366. /**
  12367. * the particle system to be used by the sub emitter
  12368. */
  12369. particleSystem: ParticleSystem;
  12370. /**
  12371. * Type of the submitter (Default: END)
  12372. */
  12373. type: SubEmitterType;
  12374. /**
  12375. * 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)
  12376. * Note: This only is supported when using an emitter of type Mesh
  12377. */
  12378. inheritDirection: boolean;
  12379. /**
  12380. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12381. */
  12382. inheritedVelocityAmount: number;
  12383. /**
  12384. * Creates a sub emitter
  12385. * @param particleSystem the particle system to be used by the sub emitter
  12386. */
  12387. constructor(
  12388. /**
  12389. * the particle system to be used by the sub emitter
  12390. */
  12391. particleSystem: ParticleSystem);
  12392. /**
  12393. * Clones the sub emitter
  12394. * @returns the cloned sub emitter
  12395. */
  12396. clone(): SubEmitter;
  12397. /**
  12398. * Serialize current object to a JSON object
  12399. * @returns the serialized object
  12400. */
  12401. serialize(): any;
  12402. /** @hidden */
  12403. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12404. /**
  12405. * Creates a new SubEmitter from a serialized JSON version
  12406. * @param serializationObject defines the JSON object to read from
  12407. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12408. * @param rootUrl defines the rootUrl for data loading
  12409. * @returns a new SubEmitter
  12410. */
  12411. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12412. /** Release associated resources */
  12413. dispose(): void;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /** @hidden */
  12418. export var imageProcessingDeclaration: {
  12419. name: string;
  12420. shader: string;
  12421. };
  12422. }
  12423. declare module BABYLON {
  12424. /** @hidden */
  12425. export var imageProcessingFunctions: {
  12426. name: string;
  12427. shader: string;
  12428. };
  12429. }
  12430. declare module BABYLON {
  12431. /** @hidden */
  12432. export var particlesPixelShader: {
  12433. name: string;
  12434. shader: string;
  12435. };
  12436. }
  12437. declare module BABYLON {
  12438. /** @hidden */
  12439. export var particlesVertexShader: {
  12440. name: string;
  12441. shader: string;
  12442. };
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Interface used to define entities containing multiple clip planes
  12447. */
  12448. export interface IClipPlanesHolder {
  12449. /**
  12450. * Gets or sets the active clipplane 1
  12451. */
  12452. clipPlane: Nullable<Plane>;
  12453. /**
  12454. * Gets or sets the active clipplane 2
  12455. */
  12456. clipPlane2: Nullable<Plane>;
  12457. /**
  12458. * Gets or sets the active clipplane 3
  12459. */
  12460. clipPlane3: Nullable<Plane>;
  12461. /**
  12462. * Gets or sets the active clipplane 4
  12463. */
  12464. clipPlane4: Nullable<Plane>;
  12465. /**
  12466. * Gets or sets the active clipplane 5
  12467. */
  12468. clipPlane5: Nullable<Plane>;
  12469. /**
  12470. * Gets or sets the active clipplane 6
  12471. */
  12472. clipPlane6: Nullable<Plane>;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12478. *
  12479. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12480. *
  12481. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12482. */
  12483. export class ThinMaterialHelper {
  12484. /**
  12485. * Binds the clip plane information from the holder to the effect.
  12486. * @param effect The effect we are binding the data to
  12487. * @param holder The entity containing the clip plane information
  12488. */
  12489. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. interface ThinEngine {
  12494. /**
  12495. * Sets alpha constants used by some alpha blending modes
  12496. * @param r defines the red component
  12497. * @param g defines the green component
  12498. * @param b defines the blue component
  12499. * @param a defines the alpha component
  12500. */
  12501. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12502. /**
  12503. * Sets the current alpha mode
  12504. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12505. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12506. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12507. */
  12508. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12509. /**
  12510. * Gets the current alpha mode
  12511. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12512. * @returns the current alpha mode
  12513. */
  12514. getAlphaMode(): number;
  12515. /**
  12516. * Sets the current alpha equation
  12517. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12518. */
  12519. setAlphaEquation(equation: number): void;
  12520. /**
  12521. * Gets the current alpha equation.
  12522. * @returns the current alpha equation
  12523. */
  12524. getAlphaEquation(): number;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /**
  12529. * This represents a particle system in Babylon.
  12530. * 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.
  12531. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12532. * @example https://doc.babylonjs.com/babylon101/particles
  12533. */
  12534. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12535. /**
  12536. * Billboard mode will only apply to Y axis
  12537. */
  12538. static readonly BILLBOARDMODE_Y: number;
  12539. /**
  12540. * Billboard mode will apply to all axes
  12541. */
  12542. static readonly BILLBOARDMODE_ALL: number;
  12543. /**
  12544. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12545. */
  12546. static readonly BILLBOARDMODE_STRETCHED: number;
  12547. /**
  12548. * This function can be defined to provide custom update for active particles.
  12549. * This function will be called instead of regular update (age, position, color, etc.).
  12550. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12551. */
  12552. updateFunction: (particles: Particle[]) => void;
  12553. private _emitterWorldMatrix;
  12554. /**
  12555. * This function can be defined to specify initial direction for every new particle.
  12556. * It by default use the emitterType defined function
  12557. */
  12558. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12559. /**
  12560. * This function can be defined to specify initial position for every new particle.
  12561. * It by default use the emitterType defined function
  12562. */
  12563. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12564. /**
  12565. * @hidden
  12566. */
  12567. _inheritedVelocityOffset: Vector3;
  12568. /**
  12569. * An event triggered when the system is disposed
  12570. */
  12571. onDisposeObservable: Observable<IParticleSystem>;
  12572. private _onDisposeObserver;
  12573. /**
  12574. * Sets a callback that will be triggered when the system is disposed
  12575. */
  12576. set onDispose(callback: () => void);
  12577. private _particles;
  12578. private _epsilon;
  12579. private _capacity;
  12580. private _stockParticles;
  12581. private _newPartsExcess;
  12582. private _vertexData;
  12583. private _vertexBuffer;
  12584. private _vertexBuffers;
  12585. private _spriteBuffer;
  12586. private _indexBuffer;
  12587. private _effect;
  12588. private _customEffect;
  12589. private _cachedDefines;
  12590. private _scaledColorStep;
  12591. private _colorDiff;
  12592. private _scaledDirection;
  12593. private _scaledGravity;
  12594. private _currentRenderId;
  12595. private _alive;
  12596. private _useInstancing;
  12597. private _started;
  12598. private _stopped;
  12599. private _actualFrame;
  12600. private _scaledUpdateSpeed;
  12601. private _vertexBufferSize;
  12602. /** @hidden */
  12603. _currentEmitRateGradient: Nullable<FactorGradient>;
  12604. /** @hidden */
  12605. _currentEmitRate1: number;
  12606. /** @hidden */
  12607. _currentEmitRate2: number;
  12608. /** @hidden */
  12609. _currentStartSizeGradient: Nullable<FactorGradient>;
  12610. /** @hidden */
  12611. _currentStartSize1: number;
  12612. /** @hidden */
  12613. _currentStartSize2: number;
  12614. private readonly _rawTextureWidth;
  12615. private _rampGradientsTexture;
  12616. private _useRampGradients;
  12617. /** Gets or sets a matrix to use to compute projection */
  12618. defaultProjectionMatrix: Matrix;
  12619. /** Gets or sets a matrix to use to compute view */
  12620. defaultViewMatrix: Matrix;
  12621. /** Gets or sets a boolean indicating that ramp gradients must be used
  12622. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12623. */
  12624. get useRampGradients(): boolean;
  12625. set useRampGradients(value: boolean);
  12626. /**
  12627. * 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.
  12628. * 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: [])
  12629. */
  12630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12631. private _subEmitters;
  12632. /**
  12633. * @hidden
  12634. * If the particle systems emitter should be disposed when the particle system is disposed
  12635. */
  12636. _disposeEmitterOnDispose: boolean;
  12637. /**
  12638. * The current active Sub-systems, this property is used by the root particle system only.
  12639. */
  12640. activeSubSystems: Array<ParticleSystem>;
  12641. /**
  12642. * Specifies if the particles are updated in emitter local space or world space
  12643. */
  12644. isLocal: boolean;
  12645. private _rootParticleSystem;
  12646. /**
  12647. * Gets the current list of active particles
  12648. */
  12649. get particles(): Particle[];
  12650. /**
  12651. * Gets the number of particles active at the same time.
  12652. * @returns The number of active particles.
  12653. */
  12654. getActiveCount(): number;
  12655. /**
  12656. * Returns the string "ParticleSystem"
  12657. * @returns a string containing the class name
  12658. */
  12659. getClassName(): string;
  12660. /**
  12661. * Gets a boolean indicating that the system is stopping
  12662. * @returns true if the system is currently stopping
  12663. */
  12664. isStopping(): boolean;
  12665. /**
  12666. * Gets the custom effect used to render the particles
  12667. * @param blendMode Blend mode for which the effect should be retrieved
  12668. * @returns The effect
  12669. */
  12670. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12671. /**
  12672. * Sets the custom effect used to render the particles
  12673. * @param effect The effect to set
  12674. * @param blendMode Blend mode for which the effect should be set
  12675. */
  12676. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12677. /** @hidden */
  12678. private _onBeforeDrawParticlesObservable;
  12679. /**
  12680. * Observable that will be called just before the particles are drawn
  12681. */
  12682. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12683. /**
  12684. * Gets the name of the particle vertex shader
  12685. */
  12686. get vertexShaderName(): string;
  12687. /**
  12688. * Instantiates a particle system.
  12689. * 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.
  12690. * @param name The name of the particle system
  12691. * @param capacity The max number of particles alive at the same time
  12692. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12693. * @param customEffect a custom effect used to change the way particles are rendered by default
  12694. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12695. * @param epsilon Offset used to render the particles
  12696. */
  12697. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12698. private _addFactorGradient;
  12699. private _removeFactorGradient;
  12700. /**
  12701. * Adds a new life time gradient
  12702. * @param gradient defines the gradient to use (between 0 and 1)
  12703. * @param factor defines the life time factor to affect to the specified gradient
  12704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12705. * @returns the current particle system
  12706. */
  12707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12708. /**
  12709. * Remove a specific life time gradient
  12710. * @param gradient defines the gradient to remove
  12711. * @returns the current particle system
  12712. */
  12713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12714. /**
  12715. * Adds a new size gradient
  12716. * @param gradient defines the gradient to use (between 0 and 1)
  12717. * @param factor defines the size factor to affect to the specified gradient
  12718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12719. * @returns the current particle system
  12720. */
  12721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12722. /**
  12723. * Remove a specific size gradient
  12724. * @param gradient defines the gradient to remove
  12725. * @returns the current particle system
  12726. */
  12727. removeSizeGradient(gradient: number): IParticleSystem;
  12728. /**
  12729. * Adds a new color remap gradient
  12730. * @param gradient defines the gradient to use (between 0 and 1)
  12731. * @param min defines the color remap minimal range
  12732. * @param max defines the color remap maximal range
  12733. * @returns the current particle system
  12734. */
  12735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12736. /**
  12737. * Remove a specific color remap gradient
  12738. * @param gradient defines the gradient to remove
  12739. * @returns the current particle system
  12740. */
  12741. removeColorRemapGradient(gradient: number): IParticleSystem;
  12742. /**
  12743. * Adds a new alpha remap gradient
  12744. * @param gradient defines the gradient to use (between 0 and 1)
  12745. * @param min defines the alpha remap minimal range
  12746. * @param max defines the alpha remap maximal range
  12747. * @returns the current particle system
  12748. */
  12749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12750. /**
  12751. * Remove a specific alpha remap gradient
  12752. * @param gradient defines the gradient to remove
  12753. * @returns the current particle system
  12754. */
  12755. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12756. /**
  12757. * Adds a new angular speed gradient
  12758. * @param gradient defines the gradient to use (between 0 and 1)
  12759. * @param factor defines the angular speed to affect to the specified gradient
  12760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12761. * @returns the current particle system
  12762. */
  12763. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12764. /**
  12765. * Remove a specific angular speed gradient
  12766. * @param gradient defines the gradient to remove
  12767. * @returns the current particle system
  12768. */
  12769. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12770. /**
  12771. * Adds a new velocity gradient
  12772. * @param gradient defines the gradient to use (between 0 and 1)
  12773. * @param factor defines the velocity to affect to the specified gradient
  12774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12775. * @returns the current particle system
  12776. */
  12777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12778. /**
  12779. * Remove a specific velocity gradient
  12780. * @param gradient defines the gradient to remove
  12781. * @returns the current particle system
  12782. */
  12783. removeVelocityGradient(gradient: number): IParticleSystem;
  12784. /**
  12785. * Adds a new limit velocity gradient
  12786. * @param gradient defines the gradient to use (between 0 and 1)
  12787. * @param factor defines the limit velocity value to affect to the specified gradient
  12788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12789. * @returns the current particle system
  12790. */
  12791. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12792. /**
  12793. * Remove a specific limit velocity gradient
  12794. * @param gradient defines the gradient to remove
  12795. * @returns the current particle system
  12796. */
  12797. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12798. /**
  12799. * Adds a new drag gradient
  12800. * @param gradient defines the gradient to use (between 0 and 1)
  12801. * @param factor defines the drag value to affect to the specified gradient
  12802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12803. * @returns the current particle system
  12804. */
  12805. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12806. /**
  12807. * Remove a specific drag gradient
  12808. * @param gradient defines the gradient to remove
  12809. * @returns the current particle system
  12810. */
  12811. removeDragGradient(gradient: number): IParticleSystem;
  12812. /**
  12813. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12814. * @param gradient defines the gradient to use (between 0 and 1)
  12815. * @param factor defines the emit rate value to affect to the specified gradient
  12816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12817. * @returns the current particle system
  12818. */
  12819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12820. /**
  12821. * Remove a specific emit rate gradient
  12822. * @param gradient defines the gradient to remove
  12823. * @returns the current particle system
  12824. */
  12825. removeEmitRateGradient(gradient: number): IParticleSystem;
  12826. /**
  12827. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12828. * @param gradient defines the gradient to use (between 0 and 1)
  12829. * @param factor defines the start size value to affect to the specified gradient
  12830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12831. * @returns the current particle system
  12832. */
  12833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12834. /**
  12835. * Remove a specific start size gradient
  12836. * @param gradient defines the gradient to remove
  12837. * @returns the current particle system
  12838. */
  12839. removeStartSizeGradient(gradient: number): IParticleSystem;
  12840. private _createRampGradientTexture;
  12841. /**
  12842. * Gets the current list of ramp gradients.
  12843. * You must use addRampGradient and removeRampGradient to udpate this list
  12844. * @returns the list of ramp gradients
  12845. */
  12846. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12847. /** Force the system to rebuild all gradients that need to be resync */
  12848. forceRefreshGradients(): void;
  12849. private _syncRampGradientTexture;
  12850. /**
  12851. * Adds a new ramp gradient used to remap particle colors
  12852. * @param gradient defines the gradient to use (between 0 and 1)
  12853. * @param color defines the color to affect to the specified gradient
  12854. * @returns the current particle system
  12855. */
  12856. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12857. /**
  12858. * Remove a specific ramp gradient
  12859. * @param gradient defines the gradient to remove
  12860. * @returns the current particle system
  12861. */
  12862. removeRampGradient(gradient: number): ParticleSystem;
  12863. /**
  12864. * Adds a new color gradient
  12865. * @param gradient defines the gradient to use (between 0 and 1)
  12866. * @param color1 defines the color to affect to the specified gradient
  12867. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12868. * @returns this particle system
  12869. */
  12870. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12871. /**
  12872. * Remove a specific color gradient
  12873. * @param gradient defines the gradient to remove
  12874. * @returns this particle system
  12875. */
  12876. removeColorGradient(gradient: number): IParticleSystem;
  12877. private _fetchR;
  12878. protected _reset(): void;
  12879. private _resetEffect;
  12880. private _createVertexBuffers;
  12881. private _createIndexBuffer;
  12882. /**
  12883. * Gets the maximum number of particles active at the same time.
  12884. * @returns The max number of active particles.
  12885. */
  12886. getCapacity(): number;
  12887. /**
  12888. * Gets whether there are still active particles in the system.
  12889. * @returns True if it is alive, otherwise false.
  12890. */
  12891. isAlive(): boolean;
  12892. /**
  12893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12894. * @returns True if it has been started, otherwise false.
  12895. */
  12896. isStarted(): boolean;
  12897. private _prepareSubEmitterInternalArray;
  12898. /**
  12899. * Starts the particle system and begins to emit
  12900. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12901. */
  12902. start(delay?: number): void;
  12903. /**
  12904. * Stops the particle system.
  12905. * @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.
  12906. */
  12907. stop(stopSubEmitters?: boolean): void;
  12908. /**
  12909. * Remove all active particles
  12910. */
  12911. reset(): void;
  12912. /**
  12913. * @hidden (for internal use only)
  12914. */
  12915. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12916. /**
  12917. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12918. * Its lifetime will start back at 0.
  12919. */
  12920. recycleParticle: (particle: Particle) => void;
  12921. private _stopSubEmitters;
  12922. private _createParticle;
  12923. private _removeFromRoot;
  12924. private _emitFromParticle;
  12925. private _update;
  12926. /** @hidden */
  12927. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12928. /** @hidden */
  12929. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12930. /**
  12931. * Fill the defines array according to the current settings of the particle system
  12932. * @param defines Array to be updated
  12933. * @param blendMode blend mode to take into account when updating the array
  12934. */
  12935. fillDefines(defines: Array<string>, blendMode: number): void;
  12936. /**
  12937. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12938. * @param uniforms Uniforms array to fill
  12939. * @param attributes Attributes array to fill
  12940. * @param samplers Samplers array to fill
  12941. */
  12942. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12943. /** @hidden */
  12944. private _getEffect;
  12945. /**
  12946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12947. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12948. */
  12949. animate(preWarmOnly?: boolean): void;
  12950. private _appendParticleVertices;
  12951. /**
  12952. * Rebuilds the particle system.
  12953. */
  12954. rebuild(): void;
  12955. /**
  12956. * Is this system ready to be used/rendered
  12957. * @return true if the system is ready
  12958. */
  12959. isReady(): boolean;
  12960. private _render;
  12961. /**
  12962. * Renders the particle system in its current state.
  12963. * @returns the current number of particles
  12964. */
  12965. render(): number;
  12966. /**
  12967. * Disposes the particle system and free the associated resources
  12968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12969. */
  12970. dispose(disposeTexture?: boolean): void;
  12971. /**
  12972. * Clones the particle system.
  12973. * @param name The name of the cloned object
  12974. * @param newEmitter The new emitter to use
  12975. * @returns the cloned particle system
  12976. */
  12977. clone(name: string, newEmitter: any): ParticleSystem;
  12978. /**
  12979. * Serializes the particle system to a JSON object
  12980. * @param serializeTexture defines if the texture must be serialized as well
  12981. * @returns the JSON object
  12982. */
  12983. serialize(serializeTexture?: boolean): any;
  12984. /** @hidden */
  12985. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12986. /** @hidden */
  12987. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12988. /**
  12989. * Parses a JSON object to create a particle system.
  12990. * @param parsedParticleSystem The JSON object to parse
  12991. * @param sceneOrEngine The scene or the engine to create the particle system in
  12992. * @param rootUrl The root url to use to load external dependencies like texture
  12993. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12994. * @returns the Parsed particle system
  12995. */
  12996. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * A particle represents one of the element emitted by a particle system.
  13002. * This is mainly define by its coordinates, direction, velocity and age.
  13003. */
  13004. export class Particle {
  13005. /**
  13006. * The particle system the particle belongs to.
  13007. */
  13008. particleSystem: ParticleSystem;
  13009. private static _Count;
  13010. /**
  13011. * Unique ID of the particle
  13012. */
  13013. id: number;
  13014. /**
  13015. * The world position of the particle in the scene.
  13016. */
  13017. position: Vector3;
  13018. /**
  13019. * The world direction of the particle in the scene.
  13020. */
  13021. direction: Vector3;
  13022. /**
  13023. * The color of the particle.
  13024. */
  13025. color: Color4;
  13026. /**
  13027. * The color change of the particle per step.
  13028. */
  13029. colorStep: Color4;
  13030. /**
  13031. * Defines how long will the life of the particle be.
  13032. */
  13033. lifeTime: number;
  13034. /**
  13035. * The current age of the particle.
  13036. */
  13037. age: number;
  13038. /**
  13039. * The current size of the particle.
  13040. */
  13041. size: number;
  13042. /**
  13043. * The current scale of the particle.
  13044. */
  13045. scale: Vector2;
  13046. /**
  13047. * The current angle of the particle.
  13048. */
  13049. angle: number;
  13050. /**
  13051. * Defines how fast is the angle changing.
  13052. */
  13053. angularSpeed: number;
  13054. /**
  13055. * Defines the cell index used by the particle to be rendered from a sprite.
  13056. */
  13057. cellIndex: number;
  13058. /**
  13059. * The information required to support color remapping
  13060. */
  13061. remapData: Vector4;
  13062. /** @hidden */
  13063. _randomCellOffset?: number;
  13064. /** @hidden */
  13065. _initialDirection: Nullable<Vector3>;
  13066. /** @hidden */
  13067. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13068. /** @hidden */
  13069. _initialStartSpriteCellID: number;
  13070. /** @hidden */
  13071. _initialEndSpriteCellID: number;
  13072. /** @hidden */
  13073. _currentColorGradient: Nullable<ColorGradient>;
  13074. /** @hidden */
  13075. _currentColor1: Color4;
  13076. /** @hidden */
  13077. _currentColor2: Color4;
  13078. /** @hidden */
  13079. _currentSizeGradient: Nullable<FactorGradient>;
  13080. /** @hidden */
  13081. _currentSize1: number;
  13082. /** @hidden */
  13083. _currentSize2: number;
  13084. /** @hidden */
  13085. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13086. /** @hidden */
  13087. _currentAngularSpeed1: number;
  13088. /** @hidden */
  13089. _currentAngularSpeed2: number;
  13090. /** @hidden */
  13091. _currentVelocityGradient: Nullable<FactorGradient>;
  13092. /** @hidden */
  13093. _currentVelocity1: number;
  13094. /** @hidden */
  13095. _currentVelocity2: number;
  13096. /** @hidden */
  13097. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13098. /** @hidden */
  13099. _currentLimitVelocity1: number;
  13100. /** @hidden */
  13101. _currentLimitVelocity2: number;
  13102. /** @hidden */
  13103. _currentDragGradient: Nullable<FactorGradient>;
  13104. /** @hidden */
  13105. _currentDrag1: number;
  13106. /** @hidden */
  13107. _currentDrag2: number;
  13108. /** @hidden */
  13109. _randomNoiseCoordinates1: Vector3;
  13110. /** @hidden */
  13111. _randomNoiseCoordinates2: Vector3;
  13112. /** @hidden */
  13113. _localPosition?: Vector3;
  13114. /**
  13115. * Creates a new instance Particle
  13116. * @param particleSystem the particle system the particle belongs to
  13117. */
  13118. constructor(
  13119. /**
  13120. * The particle system the particle belongs to.
  13121. */
  13122. particleSystem: ParticleSystem);
  13123. private updateCellInfoFromSystem;
  13124. /**
  13125. * Defines how the sprite cell index is updated for the particle
  13126. */
  13127. updateCellIndex(): void;
  13128. /** @hidden */
  13129. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13130. /** @hidden */
  13131. _inheritParticleInfoToSubEmitters(): void;
  13132. /** @hidden */
  13133. _reset(): void;
  13134. /**
  13135. * Copy the properties of particle to another one.
  13136. * @param other the particle to copy the information to.
  13137. */
  13138. copyTo(other: Particle): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Particle emitter represents a volume emitting particles.
  13144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13145. */
  13146. export interface IParticleEmitterType {
  13147. /**
  13148. * Called by the particle System when the direction is computed for the created particle.
  13149. * @param worldMatrix is the world matrix of the particle system
  13150. * @param directionToUpdate is the direction vector to update with the result
  13151. * @param particle is the particle we are computed the direction for
  13152. * @param isLocal defines if the direction should be set in local space
  13153. */
  13154. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13155. /**
  13156. * Called by the particle System when the position is computed for the created particle.
  13157. * @param worldMatrix is the world matrix of the particle system
  13158. * @param positionToUpdate is the position vector to update with the result
  13159. * @param particle is the particle we are computed the position for
  13160. * @param isLocal defines if the position should be set in local space
  13161. */
  13162. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13163. /**
  13164. * Clones the current emitter and returns a copy of it
  13165. * @returns the new emitter
  13166. */
  13167. clone(): IParticleEmitterType;
  13168. /**
  13169. * Called by the GPUParticleSystem to setup the update shader
  13170. * @param effect defines the update shader
  13171. */
  13172. applyToShader(effect: Effect): void;
  13173. /**
  13174. * Returns a string to use to update the GPU particles update shader
  13175. * @returns the effect defines string
  13176. */
  13177. getEffectDefines(): string;
  13178. /**
  13179. * Returns a string representing the class name
  13180. * @returns a string containing the class name
  13181. */
  13182. getClassName(): string;
  13183. /**
  13184. * Serializes the particle system to a JSON object.
  13185. * @returns the JSON object
  13186. */
  13187. serialize(): any;
  13188. /**
  13189. * Parse properties from a JSON object
  13190. * @param serializationObject defines the JSON object
  13191. * @param scene defines the hosting scene
  13192. */
  13193. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13194. }
  13195. }
  13196. declare module BABYLON {
  13197. /**
  13198. * Particle emitter emitting particles from the inside of a box.
  13199. * It emits the particles randomly between 2 given directions.
  13200. */
  13201. export class BoxParticleEmitter implements IParticleEmitterType {
  13202. /**
  13203. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13204. */
  13205. direction1: Vector3;
  13206. /**
  13207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13208. */
  13209. direction2: Vector3;
  13210. /**
  13211. * 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.
  13212. */
  13213. minEmitBox: Vector3;
  13214. /**
  13215. * 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.
  13216. */
  13217. maxEmitBox: Vector3;
  13218. /**
  13219. * Creates a new instance BoxParticleEmitter
  13220. */
  13221. constructor();
  13222. /**
  13223. * Called by the particle System when the direction is computed for the created particle.
  13224. * @param worldMatrix is the world matrix of the particle system
  13225. * @param directionToUpdate is the direction vector to update with the result
  13226. * @param particle is the particle we are computed the direction for
  13227. * @param isLocal defines if the direction should be set in local space
  13228. */
  13229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13230. /**
  13231. * Called by the particle System when the position is computed for the created particle.
  13232. * @param worldMatrix is the world matrix of the particle system
  13233. * @param positionToUpdate is the position vector to update with the result
  13234. * @param particle is the particle we are computed the position for
  13235. * @param isLocal defines if the position should be set in local space
  13236. */
  13237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13238. /**
  13239. * Clones the current emitter and returns a copy of it
  13240. * @returns the new emitter
  13241. */
  13242. clone(): BoxParticleEmitter;
  13243. /**
  13244. * Called by the GPUParticleSystem to setup the update shader
  13245. * @param effect defines the update shader
  13246. */
  13247. applyToShader(effect: Effect): void;
  13248. /**
  13249. * Returns a string to use to update the GPU particles update shader
  13250. * @returns a string containng the defines string
  13251. */
  13252. getEffectDefines(): string;
  13253. /**
  13254. * Returns the string "BoxParticleEmitter"
  13255. * @returns a string containing the class name
  13256. */
  13257. getClassName(): string;
  13258. /**
  13259. * Serializes the particle system to a JSON object.
  13260. * @returns the JSON object
  13261. */
  13262. serialize(): any;
  13263. /**
  13264. * Parse properties from a JSON object
  13265. * @param serializationObject defines the JSON object
  13266. */
  13267. parse(serializationObject: any): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a cone.
  13273. * It emits the particles alongside the cone volume from the base to the particle.
  13274. * The emission direction might be randomized.
  13275. */
  13276. export class ConeParticleEmitter implements IParticleEmitterType {
  13277. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13278. directionRandomizer: number;
  13279. private _radius;
  13280. private _angle;
  13281. private _height;
  13282. /**
  13283. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13284. */
  13285. radiusRange: number;
  13286. /**
  13287. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13288. */
  13289. heightRange: number;
  13290. /**
  13291. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13292. */
  13293. emitFromSpawnPointOnly: boolean;
  13294. /**
  13295. * Gets or sets the radius of the emission cone
  13296. */
  13297. get radius(): number;
  13298. set radius(value: number);
  13299. /**
  13300. * Gets or sets the angle of the emission cone
  13301. */
  13302. get angle(): number;
  13303. set angle(value: number);
  13304. private _buildHeight;
  13305. /**
  13306. * Creates a new instance ConeParticleEmitter
  13307. * @param radius the radius of the emission cone (1 by default)
  13308. * @param angle the cone base angle (PI by default)
  13309. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13310. */
  13311. constructor(radius?: number, angle?: number,
  13312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13313. directionRandomizer?: number);
  13314. /**
  13315. * Called by the particle System when the direction is computed for the created particle.
  13316. * @param worldMatrix is the world matrix of the particle system
  13317. * @param directionToUpdate is the direction vector to update with the result
  13318. * @param particle is the particle we are computed the direction for
  13319. * @param isLocal defines if the direction should be set in local space
  13320. */
  13321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13322. /**
  13323. * Called by the particle System when the position is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param positionToUpdate is the position vector to update with the result
  13326. * @param particle is the particle we are computed the position for
  13327. * @param isLocal defines if the position should be set in local space
  13328. */
  13329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Clones the current emitter and returns a copy of it
  13332. * @returns the new emitter
  13333. */
  13334. clone(): ConeParticleEmitter;
  13335. /**
  13336. * Called by the GPUParticleSystem to setup the update shader
  13337. * @param effect defines the update shader
  13338. */
  13339. applyToShader(effect: Effect): void;
  13340. /**
  13341. * Returns a string to use to update the GPU particles update shader
  13342. * @returns a string containng the defines string
  13343. */
  13344. getEffectDefines(): string;
  13345. /**
  13346. * Returns the string "ConeParticleEmitter"
  13347. * @returns a string containing the class name
  13348. */
  13349. getClassName(): string;
  13350. /**
  13351. * Serializes the particle system to a JSON object.
  13352. * @returns the JSON object
  13353. */
  13354. serialize(): any;
  13355. /**
  13356. * Parse properties from a JSON object
  13357. * @param serializationObject defines the JSON object
  13358. */
  13359. parse(serializationObject: any): void;
  13360. }
  13361. }
  13362. declare module BABYLON {
  13363. /**
  13364. * Particle emitter emitting particles from the inside of a cylinder.
  13365. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13366. */
  13367. export class CylinderParticleEmitter implements IParticleEmitterType {
  13368. /**
  13369. * The radius of the emission cylinder.
  13370. */
  13371. radius: number;
  13372. /**
  13373. * The height of the emission cylinder.
  13374. */
  13375. height: number;
  13376. /**
  13377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13378. */
  13379. radiusRange: number;
  13380. /**
  13381. * How much to randomize the particle direction [0-1].
  13382. */
  13383. directionRandomizer: number;
  13384. /**
  13385. * Creates a new instance CylinderParticleEmitter
  13386. * @param radius the radius of the emission cylinder (1 by default)
  13387. * @param height the height of the emission cylinder (1 by default)
  13388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13389. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13390. */
  13391. constructor(
  13392. /**
  13393. * The radius of the emission cylinder.
  13394. */
  13395. radius?: number,
  13396. /**
  13397. * The height of the emission cylinder.
  13398. */
  13399. height?: number,
  13400. /**
  13401. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13402. */
  13403. radiusRange?: number,
  13404. /**
  13405. * How much to randomize the particle direction [0-1].
  13406. */
  13407. directionRandomizer?: number);
  13408. /**
  13409. * Called by the particle System when the direction is computed for the created particle.
  13410. * @param worldMatrix is the world matrix of the particle system
  13411. * @param directionToUpdate is the direction vector to update with the result
  13412. * @param particle is the particle we are computed the direction for
  13413. * @param isLocal defines if the direction should be set in local space
  13414. */
  13415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13416. /**
  13417. * Called by the particle System when the position is computed for the created particle.
  13418. * @param worldMatrix is the world matrix of the particle system
  13419. * @param positionToUpdate is the position vector to update with the result
  13420. * @param particle is the particle we are computed the position for
  13421. * @param isLocal defines if the position should be set in local space
  13422. */
  13423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13424. /**
  13425. * Clones the current emitter and returns a copy of it
  13426. * @returns the new emitter
  13427. */
  13428. clone(): CylinderParticleEmitter;
  13429. /**
  13430. * Called by the GPUParticleSystem to setup the update shader
  13431. * @param effect defines the update shader
  13432. */
  13433. applyToShader(effect: Effect): void;
  13434. /**
  13435. * Returns a string to use to update the GPU particles update shader
  13436. * @returns a string containng the defines string
  13437. */
  13438. getEffectDefines(): string;
  13439. /**
  13440. * Returns the string "CylinderParticleEmitter"
  13441. * @returns a string containing the class name
  13442. */
  13443. getClassName(): string;
  13444. /**
  13445. * Serializes the particle system to a JSON object.
  13446. * @returns the JSON object
  13447. */
  13448. serialize(): any;
  13449. /**
  13450. * Parse properties from a JSON object
  13451. * @param serializationObject defines the JSON object
  13452. */
  13453. parse(serializationObject: any): void;
  13454. }
  13455. /**
  13456. * Particle emitter emitting particles from the inside of a cylinder.
  13457. * It emits the particles randomly between two vectors.
  13458. */
  13459. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13460. /**
  13461. * The min limit of the emission direction.
  13462. */
  13463. direction1: Vector3;
  13464. /**
  13465. * The max limit of the emission direction.
  13466. */
  13467. direction2: Vector3;
  13468. /**
  13469. * Creates a new instance CylinderDirectedParticleEmitter
  13470. * @param radius the radius of the emission cylinder (1 by default)
  13471. * @param height the height of the emission cylinder (1 by default)
  13472. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13473. * @param direction1 the min limit of the emission direction (up vector by default)
  13474. * @param direction2 the max limit of the emission direction (up vector by default)
  13475. */
  13476. constructor(radius?: number, height?: number, radiusRange?: number,
  13477. /**
  13478. * The min limit of the emission direction.
  13479. */
  13480. direction1?: Vector3,
  13481. /**
  13482. * The max limit of the emission direction.
  13483. */
  13484. direction2?: Vector3);
  13485. /**
  13486. * Called by the particle System when the direction is computed for the created particle.
  13487. * @param worldMatrix is the world matrix of the particle system
  13488. * @param directionToUpdate is the direction vector to update with the result
  13489. * @param particle is the particle we are computed the direction for
  13490. */
  13491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13492. /**
  13493. * Clones the current emitter and returns a copy of it
  13494. * @returns the new emitter
  13495. */
  13496. clone(): CylinderDirectedParticleEmitter;
  13497. /**
  13498. * Called by the GPUParticleSystem to setup the update shader
  13499. * @param effect defines the update shader
  13500. */
  13501. applyToShader(effect: Effect): void;
  13502. /**
  13503. * Returns a string to use to update the GPU particles update shader
  13504. * @returns a string containng the defines string
  13505. */
  13506. getEffectDefines(): string;
  13507. /**
  13508. * Returns the string "CylinderDirectedParticleEmitter"
  13509. * @returns a string containing the class name
  13510. */
  13511. getClassName(): string;
  13512. /**
  13513. * Serializes the particle system to a JSON object.
  13514. * @returns the JSON object
  13515. */
  13516. serialize(): any;
  13517. /**
  13518. * Parse properties from a JSON object
  13519. * @param serializationObject defines the JSON object
  13520. */
  13521. parse(serializationObject: any): void;
  13522. }
  13523. }
  13524. declare module BABYLON {
  13525. /**
  13526. * Particle emitter emitting particles from the inside of a hemisphere.
  13527. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13528. */
  13529. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13530. /**
  13531. * The radius of the emission hemisphere.
  13532. */
  13533. radius: number;
  13534. /**
  13535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13536. */
  13537. radiusRange: number;
  13538. /**
  13539. * How much to randomize the particle direction [0-1].
  13540. */
  13541. directionRandomizer: number;
  13542. /**
  13543. * Creates a new instance HemisphericParticleEmitter
  13544. * @param radius the radius of the emission hemisphere (1 by default)
  13545. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13546. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13547. */
  13548. constructor(
  13549. /**
  13550. * The radius of the emission hemisphere.
  13551. */
  13552. radius?: number,
  13553. /**
  13554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13555. */
  13556. radiusRange?: number,
  13557. /**
  13558. * How much to randomize the particle direction [0-1].
  13559. */
  13560. directionRandomizer?: number);
  13561. /**
  13562. * Called by the particle System when the direction is computed for the created particle.
  13563. * @param worldMatrix is the world matrix of the particle system
  13564. * @param directionToUpdate is the direction vector to update with the result
  13565. * @param particle is the particle we are computed the direction for
  13566. * @param isLocal defines if the direction should be set in local space
  13567. */
  13568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13569. /**
  13570. * Called by the particle System when the position is computed for the created particle.
  13571. * @param worldMatrix is the world matrix of the particle system
  13572. * @param positionToUpdate is the position vector to update with the result
  13573. * @param particle is the particle we are computed the position for
  13574. * @param isLocal defines if the position should be set in local space
  13575. */
  13576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13577. /**
  13578. * Clones the current emitter and returns a copy of it
  13579. * @returns the new emitter
  13580. */
  13581. clone(): HemisphericParticleEmitter;
  13582. /**
  13583. * Called by the GPUParticleSystem to setup the update shader
  13584. * @param effect defines the update shader
  13585. */
  13586. applyToShader(effect: Effect): void;
  13587. /**
  13588. * Returns a string to use to update the GPU particles update shader
  13589. * @returns a string containng the defines string
  13590. */
  13591. getEffectDefines(): string;
  13592. /**
  13593. * Returns the string "HemisphericParticleEmitter"
  13594. * @returns a string containing the class name
  13595. */
  13596. getClassName(): string;
  13597. /**
  13598. * Serializes the particle system to a JSON object.
  13599. * @returns the JSON object
  13600. */
  13601. serialize(): any;
  13602. /**
  13603. * Parse properties from a JSON object
  13604. * @param serializationObject defines the JSON object
  13605. */
  13606. parse(serializationObject: any): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. /**
  13611. * Particle emitter emitting particles from a point.
  13612. * It emits the particles randomly between 2 given directions.
  13613. */
  13614. export class PointParticleEmitter implements IParticleEmitterType {
  13615. /**
  13616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13617. */
  13618. direction1: Vector3;
  13619. /**
  13620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13621. */
  13622. direction2: Vector3;
  13623. /**
  13624. * Creates a new instance PointParticleEmitter
  13625. */
  13626. constructor();
  13627. /**
  13628. * Called by the particle System when the direction is computed for the created particle.
  13629. * @param worldMatrix is the world matrix of the particle system
  13630. * @param directionToUpdate is the direction vector to update with the result
  13631. * @param particle is the particle we are computed the direction for
  13632. * @param isLocal defines if the direction should be set in local space
  13633. */
  13634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13635. /**
  13636. * Called by the particle System when the position is computed for the created particle.
  13637. * @param worldMatrix is the world matrix of the particle system
  13638. * @param positionToUpdate is the position vector to update with the result
  13639. * @param particle is the particle we are computed the position for
  13640. * @param isLocal defines if the position should be set in local space
  13641. */
  13642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13643. /**
  13644. * Clones the current emitter and returns a copy of it
  13645. * @returns the new emitter
  13646. */
  13647. clone(): PointParticleEmitter;
  13648. /**
  13649. * Called by the GPUParticleSystem to setup the update shader
  13650. * @param effect defines the update shader
  13651. */
  13652. applyToShader(effect: Effect): void;
  13653. /**
  13654. * Returns a string to use to update the GPU particles update shader
  13655. * @returns a string containng the defines string
  13656. */
  13657. getEffectDefines(): string;
  13658. /**
  13659. * Returns the string "PointParticleEmitter"
  13660. * @returns a string containing the class name
  13661. */
  13662. getClassName(): string;
  13663. /**
  13664. * Serializes the particle system to a JSON object.
  13665. * @returns the JSON object
  13666. */
  13667. serialize(): any;
  13668. /**
  13669. * Parse properties from a JSON object
  13670. * @param serializationObject defines the JSON object
  13671. */
  13672. parse(serializationObject: any): void;
  13673. }
  13674. }
  13675. declare module BABYLON {
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a sphere.
  13678. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13679. */
  13680. export class SphereParticleEmitter implements IParticleEmitterType {
  13681. /**
  13682. * The radius of the emission sphere.
  13683. */
  13684. radius: number;
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange: number;
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer: number;
  13693. /**
  13694. * Creates a new instance SphereParticleEmitter
  13695. * @param radius the radius of the emission sphere (1 by default)
  13696. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13697. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13698. */
  13699. constructor(
  13700. /**
  13701. * The radius of the emission sphere.
  13702. */
  13703. radius?: number,
  13704. /**
  13705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13706. */
  13707. radiusRange?: number,
  13708. /**
  13709. * How much to randomize the particle direction [0-1].
  13710. */
  13711. directionRandomizer?: number);
  13712. /**
  13713. * Called by the particle System when the direction is computed for the created particle.
  13714. * @param worldMatrix is the world matrix of the particle system
  13715. * @param directionToUpdate is the direction vector to update with the result
  13716. * @param particle is the particle we are computed the direction for
  13717. * @param isLocal defines if the direction should be set in local space
  13718. */
  13719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13720. /**
  13721. * Called by the particle System when the position is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param positionToUpdate is the position vector to update with the result
  13724. * @param particle is the particle we are computed the position for
  13725. * @param isLocal defines if the position should be set in local space
  13726. */
  13727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Clones the current emitter and returns a copy of it
  13730. * @returns the new emitter
  13731. */
  13732. clone(): SphereParticleEmitter;
  13733. /**
  13734. * Called by the GPUParticleSystem to setup the update shader
  13735. * @param effect defines the update shader
  13736. */
  13737. applyToShader(effect: Effect): void;
  13738. /**
  13739. * Returns a string to use to update the GPU particles update shader
  13740. * @returns a string containng the defines string
  13741. */
  13742. getEffectDefines(): string;
  13743. /**
  13744. * Returns the string "SphereParticleEmitter"
  13745. * @returns a string containing the class name
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Serializes the particle system to a JSON object.
  13750. * @returns the JSON object
  13751. */
  13752. serialize(): any;
  13753. /**
  13754. * Parse properties from a JSON object
  13755. * @param serializationObject defines the JSON object
  13756. */
  13757. parse(serializationObject: any): void;
  13758. }
  13759. /**
  13760. * Particle emitter emitting particles from the inside of a sphere.
  13761. * It emits the particles randomly between two vectors.
  13762. */
  13763. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13764. /**
  13765. * The min limit of the emission direction.
  13766. */
  13767. direction1: Vector3;
  13768. /**
  13769. * The max limit of the emission direction.
  13770. */
  13771. direction2: Vector3;
  13772. /**
  13773. * Creates a new instance SphereDirectedParticleEmitter
  13774. * @param radius the radius of the emission sphere (1 by default)
  13775. * @param direction1 the min limit of the emission direction (up vector by default)
  13776. * @param direction2 the max limit of the emission direction (up vector by default)
  13777. */
  13778. constructor(radius?: number,
  13779. /**
  13780. * The min limit of the emission direction.
  13781. */
  13782. direction1?: Vector3,
  13783. /**
  13784. * The max limit of the emission direction.
  13785. */
  13786. direction2?: Vector3);
  13787. /**
  13788. * Called by the particle System when the direction is computed for the created particle.
  13789. * @param worldMatrix is the world matrix of the particle system
  13790. * @param directionToUpdate is the direction vector to update with the result
  13791. * @param particle is the particle we are computed the direction for
  13792. */
  13793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13794. /**
  13795. * Clones the current emitter and returns a copy of it
  13796. * @returns the new emitter
  13797. */
  13798. clone(): SphereDirectedParticleEmitter;
  13799. /**
  13800. * Called by the GPUParticleSystem to setup the update shader
  13801. * @param effect defines the update shader
  13802. */
  13803. applyToShader(effect: Effect): void;
  13804. /**
  13805. * Returns a string to use to update the GPU particles update shader
  13806. * @returns a string containng the defines string
  13807. */
  13808. getEffectDefines(): string;
  13809. /**
  13810. * Returns the string "SphereDirectedParticleEmitter"
  13811. * @returns a string containing the class name
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Serializes the particle system to a JSON object.
  13816. * @returns the JSON object
  13817. */
  13818. serialize(): any;
  13819. /**
  13820. * Parse properties from a JSON object
  13821. * @param serializationObject defines the JSON object
  13822. */
  13823. parse(serializationObject: any): void;
  13824. }
  13825. }
  13826. declare module BABYLON {
  13827. /**
  13828. * Particle emitter emitting particles from a custom list of positions.
  13829. */
  13830. export class CustomParticleEmitter implements IParticleEmitterType {
  13831. /**
  13832. * Gets or sets the position generator that will create the inital position of each particle.
  13833. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13834. */
  13835. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13836. /**
  13837. * Gets or sets the destination generator that will create the final destination of each particle.
  13838. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13839. */
  13840. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13841. /**
  13842. * Creates a new instance CustomParticleEmitter
  13843. */
  13844. constructor();
  13845. /**
  13846. * Called by the particle System when the direction is computed for the created particle.
  13847. * @param worldMatrix is the world matrix of the particle system
  13848. * @param directionToUpdate is the direction vector to update with the result
  13849. * @param particle is the particle we are computed the direction for
  13850. * @param isLocal defines if the direction should be set in local space
  13851. */
  13852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13853. /**
  13854. * Called by the particle System when the position is computed for the created particle.
  13855. * @param worldMatrix is the world matrix of the particle system
  13856. * @param positionToUpdate is the position vector to update with the result
  13857. * @param particle is the particle we are computed the position for
  13858. * @param isLocal defines if the position should be set in local space
  13859. */
  13860. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13861. /**
  13862. * Clones the current emitter and returns a copy of it
  13863. * @returns the new emitter
  13864. */
  13865. clone(): CustomParticleEmitter;
  13866. /**
  13867. * Called by the GPUParticleSystem to setup the update shader
  13868. * @param effect defines the update shader
  13869. */
  13870. applyToShader(effect: Effect): void;
  13871. /**
  13872. * Returns a string to use to update the GPU particles update shader
  13873. * @returns a string containng the defines string
  13874. */
  13875. getEffectDefines(): string;
  13876. /**
  13877. * Returns the string "PointParticleEmitter"
  13878. * @returns a string containing the class name
  13879. */
  13880. getClassName(): string;
  13881. /**
  13882. * Serializes the particle system to a JSON object.
  13883. * @returns the JSON object
  13884. */
  13885. serialize(): any;
  13886. /**
  13887. * Parse properties from a JSON object
  13888. * @param serializationObject defines the JSON object
  13889. */
  13890. parse(serializationObject: any): void;
  13891. }
  13892. }
  13893. declare module BABYLON {
  13894. /**
  13895. * Particle emitter emitting particles from the inside of a box.
  13896. * It emits the particles randomly between 2 given directions.
  13897. */
  13898. export class MeshParticleEmitter implements IParticleEmitterType {
  13899. private _indices;
  13900. private _positions;
  13901. private _normals;
  13902. private _storedNormal;
  13903. private _mesh;
  13904. /**
  13905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13914. */
  13915. useMeshNormalsForDirection: boolean;
  13916. /** Defines the mesh to use as source */
  13917. get mesh(): Nullable<AbstractMesh>;
  13918. set mesh(value: Nullable<AbstractMesh>);
  13919. /**
  13920. * Creates a new instance MeshParticleEmitter
  13921. * @param mesh defines the mesh to use as source
  13922. */
  13923. constructor(mesh?: Nullable<AbstractMesh>);
  13924. /**
  13925. * Called by the particle System when the direction is computed for the created particle.
  13926. * @param worldMatrix is the world matrix of the particle system
  13927. * @param directionToUpdate is the direction vector to update with the result
  13928. * @param particle is the particle we are computed the direction for
  13929. * @param isLocal defines if the direction should be set in local space
  13930. */
  13931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13932. /**
  13933. * Called by the particle System when the position is computed for the created particle.
  13934. * @param worldMatrix is the world matrix of the particle system
  13935. * @param positionToUpdate is the position vector to update with the result
  13936. * @param particle is the particle we are computed the position for
  13937. * @param isLocal defines if the position should be set in local space
  13938. */
  13939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13940. /**
  13941. * Clones the current emitter and returns a copy of it
  13942. * @returns the new emitter
  13943. */
  13944. clone(): MeshParticleEmitter;
  13945. /**
  13946. * Called by the GPUParticleSystem to setup the update shader
  13947. * @param effect defines the update shader
  13948. */
  13949. applyToShader(effect: Effect): void;
  13950. /**
  13951. * Returns a string to use to update the GPU particles update shader
  13952. * @returns a string containng the defines string
  13953. */
  13954. getEffectDefines(): string;
  13955. /**
  13956. * Returns the string "BoxParticleEmitter"
  13957. * @returns a string containing the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Serializes the particle system to a JSON object.
  13962. * @returns the JSON object
  13963. */
  13964. serialize(): any;
  13965. /**
  13966. * Parse properties from a JSON object
  13967. * @param serializationObject defines the JSON object
  13968. * @param scene defines the hosting scene
  13969. */
  13970. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13971. }
  13972. }
  13973. declare module BABYLON {
  13974. /**
  13975. * Interface representing a particle system in Babylon.js.
  13976. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13977. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13978. */
  13979. export interface IParticleSystem {
  13980. /**
  13981. * List of animations used by the particle system.
  13982. */
  13983. animations: Animation[];
  13984. /**
  13985. * The id of the Particle system.
  13986. */
  13987. id: string;
  13988. /**
  13989. * The name of the Particle system.
  13990. */
  13991. name: string;
  13992. /**
  13993. * The emitter represents the Mesh or position we are attaching the particle system to.
  13994. */
  13995. emitter: Nullable<AbstractMesh | Vector3>;
  13996. /**
  13997. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13998. */
  13999. isBillboardBased: boolean;
  14000. /**
  14001. * The rendering group used by the Particle system to chose when to render.
  14002. */
  14003. renderingGroupId: number;
  14004. /**
  14005. * The layer mask we are rendering the particles through.
  14006. */
  14007. layerMask: number;
  14008. /**
  14009. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14010. */
  14011. updateSpeed: number;
  14012. /**
  14013. * The amount of time the particle system is running (depends of the overall update speed).
  14014. */
  14015. targetStopDuration: number;
  14016. /**
  14017. * The texture used to render each particle. (this can be a spritesheet)
  14018. */
  14019. particleTexture: Nullable<BaseTexture>;
  14020. /**
  14021. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14022. */
  14023. blendMode: number;
  14024. /**
  14025. * Minimum life time of emitting particles.
  14026. */
  14027. minLifeTime: number;
  14028. /**
  14029. * Maximum life time of emitting particles.
  14030. */
  14031. maxLifeTime: number;
  14032. /**
  14033. * Minimum Size of emitting particles.
  14034. */
  14035. minSize: number;
  14036. /**
  14037. * Maximum Size of emitting particles.
  14038. */
  14039. maxSize: number;
  14040. /**
  14041. * Minimum scale of emitting particles on X axis.
  14042. */
  14043. minScaleX: number;
  14044. /**
  14045. * Maximum scale of emitting particles on X axis.
  14046. */
  14047. maxScaleX: number;
  14048. /**
  14049. * Minimum scale of emitting particles on Y axis.
  14050. */
  14051. minScaleY: number;
  14052. /**
  14053. * Maximum scale of emitting particles on Y axis.
  14054. */
  14055. maxScaleY: number;
  14056. /**
  14057. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14058. */
  14059. color1: Color4;
  14060. /**
  14061. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14062. */
  14063. color2: Color4;
  14064. /**
  14065. * Color the particle will have at the end of its lifetime.
  14066. */
  14067. colorDead: Color4;
  14068. /**
  14069. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14070. */
  14071. emitRate: number;
  14072. /**
  14073. * You can use gravity if you want to give an orientation to your particles.
  14074. */
  14075. gravity: Vector3;
  14076. /**
  14077. * Minimum power of emitting particles.
  14078. */
  14079. minEmitPower: number;
  14080. /**
  14081. * Maximum power of emitting particles.
  14082. */
  14083. maxEmitPower: number;
  14084. /**
  14085. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14086. */
  14087. minAngularSpeed: number;
  14088. /**
  14089. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14090. */
  14091. maxAngularSpeed: number;
  14092. /**
  14093. * Gets or sets the minimal initial rotation in radians.
  14094. */
  14095. minInitialRotation: number;
  14096. /**
  14097. * Gets or sets the maximal initial rotation in radians.
  14098. */
  14099. maxInitialRotation: number;
  14100. /**
  14101. * The particle emitter type defines the emitter used by the particle system.
  14102. * It can be for example box, sphere, or cone...
  14103. */
  14104. particleEmitterType: Nullable<IParticleEmitterType>;
  14105. /**
  14106. * Defines the delay in milliseconds before starting the system (0 by default)
  14107. */
  14108. startDelay: number;
  14109. /**
  14110. * 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
  14111. */
  14112. preWarmCycles: number;
  14113. /**
  14114. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14115. */
  14116. preWarmStepOffset: number;
  14117. /**
  14118. * 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)
  14119. */
  14120. spriteCellChangeSpeed: number;
  14121. /**
  14122. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14123. */
  14124. startSpriteCellID: number;
  14125. /**
  14126. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14127. */
  14128. endSpriteCellID: number;
  14129. /**
  14130. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14131. */
  14132. spriteCellWidth: number;
  14133. /**
  14134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14135. */
  14136. spriteCellHeight: number;
  14137. /**
  14138. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14139. */
  14140. spriteRandomStartCell: boolean;
  14141. /**
  14142. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14143. */
  14144. isAnimationSheetEnabled: boolean;
  14145. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14146. translationPivot: Vector2;
  14147. /**
  14148. * Gets or sets a texture used to add random noise to particle positions
  14149. */
  14150. noiseTexture: Nullable<BaseTexture>;
  14151. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14152. noiseStrength: Vector3;
  14153. /**
  14154. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14155. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14156. */
  14157. billboardMode: number;
  14158. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14159. limitVelocityDamping: number;
  14160. /**
  14161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14162. */
  14163. beginAnimationOnStart: boolean;
  14164. /**
  14165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14166. */
  14167. beginAnimationFrom: number;
  14168. /**
  14169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14170. */
  14171. beginAnimationTo: number;
  14172. /**
  14173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14174. */
  14175. beginAnimationLoop: boolean;
  14176. /**
  14177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14178. */
  14179. disposeOnStop: boolean;
  14180. /**
  14181. * Specifies if the particles are updated in emitter local space or world space
  14182. */
  14183. isLocal: boolean;
  14184. /** Snippet ID if the particle system was created from the snippet server */
  14185. snippetId: string;
  14186. /** Gets or sets a matrix to use to compute projection */
  14187. defaultProjectionMatrix: Matrix;
  14188. /**
  14189. * Gets the maximum number of particles active at the same time.
  14190. * @returns The max number of active particles.
  14191. */
  14192. getCapacity(): number;
  14193. /**
  14194. * Gets the number of particles active at the same time.
  14195. * @returns The number of active particles.
  14196. */
  14197. getActiveCount(): number;
  14198. /**
  14199. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14200. * @returns True if it has been started, otherwise false.
  14201. */
  14202. isStarted(): boolean;
  14203. /**
  14204. * Animates the particle system for this frame.
  14205. */
  14206. animate(): void;
  14207. /**
  14208. * Renders the particle system in its current state.
  14209. * @returns the current number of particles
  14210. */
  14211. render(): number;
  14212. /**
  14213. * Dispose the particle system and frees its associated resources.
  14214. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14215. */
  14216. dispose(disposeTexture?: boolean): void;
  14217. /**
  14218. * An event triggered when the system is disposed
  14219. */
  14220. onDisposeObservable: Observable<IParticleSystem>;
  14221. /**
  14222. * Clones the particle system.
  14223. * @param name The name of the cloned object
  14224. * @param newEmitter The new emitter to use
  14225. * @returns the cloned particle system
  14226. */
  14227. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14228. /**
  14229. * Serializes the particle system to a JSON object
  14230. * @param serializeTexture defines if the texture must be serialized as well
  14231. * @returns the JSON object
  14232. */
  14233. serialize(serializeTexture: boolean): any;
  14234. /**
  14235. * Rebuild the particle system
  14236. */
  14237. rebuild(): void;
  14238. /** Force the system to rebuild all gradients that need to be resync */
  14239. forceRefreshGradients(): void;
  14240. /**
  14241. * Starts the particle system and begins to emit
  14242. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14243. */
  14244. start(delay?: number): void;
  14245. /**
  14246. * Stops the particle system.
  14247. */
  14248. stop(): void;
  14249. /**
  14250. * Remove all active particles
  14251. */
  14252. reset(): void;
  14253. /**
  14254. * Gets a boolean indicating that the system is stopping
  14255. * @returns true if the system is currently stopping
  14256. */
  14257. isStopping(): boolean;
  14258. /**
  14259. * Is this system ready to be used/rendered
  14260. * @return true if the system is ready
  14261. */
  14262. isReady(): boolean;
  14263. /**
  14264. * Returns the string "ParticleSystem"
  14265. * @returns a string containing the class name
  14266. */
  14267. getClassName(): string;
  14268. /**
  14269. * Gets the custom effect used to render the particles
  14270. * @param blendMode Blend mode for which the effect should be retrieved
  14271. * @returns The effect
  14272. */
  14273. getCustomEffect(blendMode: number): Nullable<Effect>;
  14274. /**
  14275. * Sets the custom effect used to render the particles
  14276. * @param effect The effect to set
  14277. * @param blendMode Blend mode for which the effect should be set
  14278. */
  14279. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14280. /**
  14281. * Fill the defines array according to the current settings of the particle system
  14282. * @param defines Array to be updated
  14283. * @param blendMode blend mode to take into account when updating the array
  14284. */
  14285. fillDefines(defines: Array<string>, blendMode: number): void;
  14286. /**
  14287. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14288. * @param uniforms Uniforms array to fill
  14289. * @param attributes Attributes array to fill
  14290. * @param samplers Samplers array to fill
  14291. */
  14292. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14293. /**
  14294. * Observable that will be called just before the particles are drawn
  14295. */
  14296. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14297. /**
  14298. * Gets the name of the particle vertex shader
  14299. */
  14300. vertexShaderName: string;
  14301. /**
  14302. * Adds a new color gradient
  14303. * @param gradient defines the gradient to use (between 0 and 1)
  14304. * @param color1 defines the color to affect to the specified gradient
  14305. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14306. * @returns the current particle system
  14307. */
  14308. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14309. /**
  14310. * Remove a specific color gradient
  14311. * @param gradient defines the gradient to remove
  14312. * @returns the current particle system
  14313. */
  14314. removeColorGradient(gradient: number): IParticleSystem;
  14315. /**
  14316. * Adds a new size gradient
  14317. * @param gradient defines the gradient to use (between 0 and 1)
  14318. * @param factor defines the size factor to affect to the specified gradient
  14319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14320. * @returns the current particle system
  14321. */
  14322. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14323. /**
  14324. * Remove a specific size gradient
  14325. * @param gradient defines the gradient to remove
  14326. * @returns the current particle system
  14327. */
  14328. removeSizeGradient(gradient: number): IParticleSystem;
  14329. /**
  14330. * Gets the current list of color gradients.
  14331. * You must use addColorGradient and removeColorGradient to udpate this list
  14332. * @returns the list of color gradients
  14333. */
  14334. getColorGradients(): Nullable<Array<ColorGradient>>;
  14335. /**
  14336. * Gets the current list of size gradients.
  14337. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14338. * @returns the list of size gradients
  14339. */
  14340. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14341. /**
  14342. * Gets the current list of angular speed gradients.
  14343. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14344. * @returns the list of angular speed gradients
  14345. */
  14346. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14347. /**
  14348. * Adds a new angular speed gradient
  14349. * @param gradient defines the gradient to use (between 0 and 1)
  14350. * @param factor defines the angular speed to affect to the specified gradient
  14351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14352. * @returns the current particle system
  14353. */
  14354. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14355. /**
  14356. * Remove a specific angular speed gradient
  14357. * @param gradient defines the gradient to remove
  14358. * @returns the current particle system
  14359. */
  14360. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14361. /**
  14362. * Gets the current list of velocity gradients.
  14363. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14364. * @returns the list of velocity gradients
  14365. */
  14366. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Adds a new velocity gradient
  14369. * @param gradient defines the gradient to use (between 0 and 1)
  14370. * @param factor defines the velocity to affect to the specified gradient
  14371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14372. * @returns the current particle system
  14373. */
  14374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14375. /**
  14376. * Remove a specific velocity gradient
  14377. * @param gradient defines the gradient to remove
  14378. * @returns the current particle system
  14379. */
  14380. removeVelocityGradient(gradient: number): IParticleSystem;
  14381. /**
  14382. * Gets the current list of limit velocity gradients.
  14383. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14384. * @returns the list of limit velocity gradients
  14385. */
  14386. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14387. /**
  14388. * Adds a new limit velocity gradient
  14389. * @param gradient defines the gradient to use (between 0 and 1)
  14390. * @param factor defines the limit velocity to affect to the specified gradient
  14391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14392. * @returns the current particle system
  14393. */
  14394. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14395. /**
  14396. * Remove a specific limit velocity gradient
  14397. * @param gradient defines the gradient to remove
  14398. * @returns the current particle system
  14399. */
  14400. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14401. /**
  14402. * Adds a new drag gradient
  14403. * @param gradient defines the gradient to use (between 0 and 1)
  14404. * @param factor defines the drag to affect to the specified gradient
  14405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14406. * @returns the current particle system
  14407. */
  14408. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14409. /**
  14410. * Remove a specific drag gradient
  14411. * @param gradient defines the gradient to remove
  14412. * @returns the current particle system
  14413. */
  14414. removeDragGradient(gradient: number): IParticleSystem;
  14415. /**
  14416. * Gets the current list of drag gradients.
  14417. * You must use addDragGradient and removeDragGradient to udpate this list
  14418. * @returns the list of drag gradients
  14419. */
  14420. getDragGradients(): Nullable<Array<FactorGradient>>;
  14421. /**
  14422. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param factor defines the emit rate to affect to the specified gradient
  14425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14426. * @returns the current particle system
  14427. */
  14428. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14429. /**
  14430. * Remove a specific emit rate gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeEmitRateGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Gets the current list of emit rate gradients.
  14437. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14438. * @returns the list of emit rate gradients
  14439. */
  14440. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14441. /**
  14442. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14443. * @param gradient defines the gradient to use (between 0 and 1)
  14444. * @param factor defines the start size to affect to the specified gradient
  14445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14446. * @returns the current particle system
  14447. */
  14448. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14449. /**
  14450. * Remove a specific start size gradient
  14451. * @param gradient defines the gradient to remove
  14452. * @returns the current particle system
  14453. */
  14454. removeStartSizeGradient(gradient: number): IParticleSystem;
  14455. /**
  14456. * Gets the current list of start size gradients.
  14457. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14458. * @returns the list of start size gradients
  14459. */
  14460. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Adds a new life time gradient
  14463. * @param gradient defines the gradient to use (between 0 and 1)
  14464. * @param factor defines the life time factor to affect to the specified gradient
  14465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14466. * @returns the current particle system
  14467. */
  14468. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14469. /**
  14470. * Remove a specific life time gradient
  14471. * @param gradient defines the gradient to remove
  14472. * @returns the current particle system
  14473. */
  14474. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14475. /**
  14476. * Gets the current list of life time gradients.
  14477. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14478. * @returns the list of life time gradients
  14479. */
  14480. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of color gradients.
  14483. * You must use addColorGradient and removeColorGradient to udpate this list
  14484. * @returns the list of color gradients
  14485. */
  14486. getColorGradients(): Nullable<Array<ColorGradient>>;
  14487. /**
  14488. * Adds a new ramp gradient used to remap particle colors
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param color defines the color to affect to the specified gradient
  14491. * @returns the current particle system
  14492. */
  14493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14494. /**
  14495. * Gets the current list of ramp gradients.
  14496. * You must use addRampGradient and removeRampGradient to udpate this list
  14497. * @returns the list of ramp gradients
  14498. */
  14499. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14500. /** Gets or sets a boolean indicating that ramp gradients must be used
  14501. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14502. */
  14503. useRampGradients: boolean;
  14504. /**
  14505. * Adds a new color remap gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param min defines the color remap minimal range
  14508. * @param max defines the color remap maximal range
  14509. * @returns the current particle system
  14510. */
  14511. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14512. /**
  14513. * Gets the current list of color remap gradients.
  14514. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14515. * @returns the list of color remap gradients
  14516. */
  14517. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14518. /**
  14519. * Adds a new alpha remap gradient
  14520. * @param gradient defines the gradient to use (between 0 and 1)
  14521. * @param min defines the alpha remap minimal range
  14522. * @param max defines the alpha remap maximal range
  14523. * @returns the current particle system
  14524. */
  14525. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14526. /**
  14527. * Gets the current list of alpha remap gradients.
  14528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14529. * @returns the list of alpha remap gradients
  14530. */
  14531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @returns the emitter
  14537. */
  14538. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14539. /**
  14540. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14541. * @param radius The radius of the hemisphere to emit from
  14542. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14543. * @returns the emitter
  14544. */
  14545. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14546. /**
  14547. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14548. * @param radius The radius of the sphere to emit from
  14549. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14550. * @returns the emitter
  14551. */
  14552. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14553. /**
  14554. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14555. * @param radius The radius of the sphere to emit from
  14556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @returns the emitter
  14559. */
  14560. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14561. /**
  14562. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14563. * @param radius The radius of the emission cylinder
  14564. * @param height The height of the emission cylinder
  14565. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14566. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14567. * @returns the emitter
  14568. */
  14569. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14570. /**
  14571. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14572. * @param radius The radius of the cylinder to emit from
  14573. * @param height The height of the emission cylinder
  14574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @returns the emitter
  14578. */
  14579. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14580. /**
  14581. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14582. * @param radius The radius of the cone to emit from
  14583. * @param angle The base angle of the cone
  14584. * @returns the emitter
  14585. */
  14586. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14587. /**
  14588. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14592. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @returns the emitter
  14594. */
  14595. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14596. /**
  14597. * Get hosting scene
  14598. * @returns the scene
  14599. */
  14600. getScene(): Nullable<Scene>;
  14601. }
  14602. }
  14603. declare module BABYLON {
  14604. /**
  14605. * 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.
  14606. * @see https://doc.babylonjs.com/how_to/transformnode
  14607. */
  14608. export class TransformNode extends Node {
  14609. /**
  14610. * Object will not rotate to face the camera
  14611. */
  14612. static BILLBOARDMODE_NONE: number;
  14613. /**
  14614. * Object will rotate to face the camera but only on the x axis
  14615. */
  14616. static BILLBOARDMODE_X: number;
  14617. /**
  14618. * Object will rotate to face the camera but only on the y axis
  14619. */
  14620. static BILLBOARDMODE_Y: number;
  14621. /**
  14622. * Object will rotate to face the camera but only on the z axis
  14623. */
  14624. static BILLBOARDMODE_Z: number;
  14625. /**
  14626. * Object will rotate to face the camera
  14627. */
  14628. static BILLBOARDMODE_ALL: number;
  14629. /**
  14630. * Object will rotate to face the camera's position instead of orientation
  14631. */
  14632. static BILLBOARDMODE_USE_POSITION: number;
  14633. private static _TmpRotation;
  14634. private static _TmpScaling;
  14635. private static _TmpTranslation;
  14636. private _forward;
  14637. private _forwardInverted;
  14638. private _up;
  14639. private _right;
  14640. private _rightInverted;
  14641. private _position;
  14642. private _rotation;
  14643. private _rotationQuaternion;
  14644. protected _scaling: Vector3;
  14645. protected _isDirty: boolean;
  14646. private _transformToBoneReferal;
  14647. private _isAbsoluteSynced;
  14648. private _billboardMode;
  14649. /**
  14650. * Gets or sets the billboard mode. Default is 0.
  14651. *
  14652. * | Value | Type | Description |
  14653. * | --- | --- | --- |
  14654. * | 0 | BILLBOARDMODE_NONE | |
  14655. * | 1 | BILLBOARDMODE_X | |
  14656. * | 2 | BILLBOARDMODE_Y | |
  14657. * | 4 | BILLBOARDMODE_Z | |
  14658. * | 7 | BILLBOARDMODE_ALL | |
  14659. *
  14660. */
  14661. get billboardMode(): number;
  14662. set billboardMode(value: number);
  14663. private _preserveParentRotationForBillboard;
  14664. /**
  14665. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14666. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14667. */
  14668. get preserveParentRotationForBillboard(): boolean;
  14669. set preserveParentRotationForBillboard(value: boolean);
  14670. /**
  14671. * 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
  14672. */
  14673. scalingDeterminant: number;
  14674. private _infiniteDistance;
  14675. /**
  14676. * Gets or sets the distance of the object to max, often used by skybox
  14677. */
  14678. get infiniteDistance(): boolean;
  14679. set infiniteDistance(value: boolean);
  14680. /**
  14681. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14682. * By default the system will update normals to compensate
  14683. */
  14684. ignoreNonUniformScaling: boolean;
  14685. /**
  14686. * 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
  14687. */
  14688. reIntegrateRotationIntoRotationQuaternion: boolean;
  14689. /** @hidden */
  14690. _poseMatrix: Nullable<Matrix>;
  14691. /** @hidden */
  14692. _localMatrix: Matrix;
  14693. private _usePivotMatrix;
  14694. private _absolutePosition;
  14695. private _absoluteScaling;
  14696. private _absoluteRotationQuaternion;
  14697. private _pivotMatrix;
  14698. private _pivotMatrixInverse;
  14699. /** @hidden */
  14700. _postMultiplyPivotMatrix: boolean;
  14701. protected _isWorldMatrixFrozen: boolean;
  14702. /** @hidden */
  14703. _indexInSceneTransformNodesArray: number;
  14704. /**
  14705. * An event triggered after the world matrix is updated
  14706. */
  14707. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14708. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14709. /**
  14710. * Gets a string identifying the name of the class
  14711. * @returns "TransformNode" string
  14712. */
  14713. getClassName(): string;
  14714. /**
  14715. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14716. */
  14717. get position(): Vector3;
  14718. set position(newPosition: Vector3);
  14719. /**
  14720. * 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)).
  14721. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14722. */
  14723. get rotation(): Vector3;
  14724. set rotation(newRotation: Vector3);
  14725. /**
  14726. * 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)).
  14727. */
  14728. get scaling(): Vector3;
  14729. set scaling(newScaling: Vector3);
  14730. /**
  14731. * 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).
  14732. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14733. */
  14734. get rotationQuaternion(): Nullable<Quaternion>;
  14735. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14736. /**
  14737. * The forward direction of that transform in world space.
  14738. */
  14739. get forward(): Vector3;
  14740. /**
  14741. * The up direction of that transform in world space.
  14742. */
  14743. get up(): Vector3;
  14744. /**
  14745. * The right direction of that transform in world space.
  14746. */
  14747. get right(): Vector3;
  14748. /**
  14749. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14750. * @param matrix the matrix to copy the pose from
  14751. * @returns this TransformNode.
  14752. */
  14753. updatePoseMatrix(matrix: Matrix): TransformNode;
  14754. /**
  14755. * Returns the mesh Pose matrix.
  14756. * @returns the pose matrix
  14757. */
  14758. getPoseMatrix(): Matrix;
  14759. /** @hidden */
  14760. _isSynchronized(): boolean;
  14761. /** @hidden */
  14762. _initCache(): void;
  14763. /**
  14764. * Flag the transform node as dirty (Forcing it to update everything)
  14765. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14766. * @returns this transform node
  14767. */
  14768. markAsDirty(property: string): TransformNode;
  14769. /**
  14770. * Returns the current mesh absolute position.
  14771. * Returns a Vector3.
  14772. */
  14773. get absolutePosition(): Vector3;
  14774. /**
  14775. * Returns the current mesh absolute scaling.
  14776. * Returns a Vector3.
  14777. */
  14778. get absoluteScaling(): Vector3;
  14779. /**
  14780. * Returns the current mesh absolute rotation.
  14781. * Returns a Quaternion.
  14782. */
  14783. get absoluteRotationQuaternion(): Quaternion;
  14784. /**
  14785. * Sets a new matrix to apply before all other transformation
  14786. * @param matrix defines the transform matrix
  14787. * @returns the current TransformNode
  14788. */
  14789. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14790. /**
  14791. * Sets a new pivot matrix to the current node
  14792. * @param matrix defines the new pivot matrix to use
  14793. * @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
  14794. * @returns the current TransformNode
  14795. */
  14796. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14797. /**
  14798. * Returns the mesh pivot matrix.
  14799. * Default : Identity.
  14800. * @returns the matrix
  14801. */
  14802. getPivotMatrix(): Matrix;
  14803. /**
  14804. * Instantiate (when possible) or clone that node with its hierarchy
  14805. * @param newParent defines the new parent to use for the instance (or clone)
  14806. * @param options defines options to configure how copy is done
  14807. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14808. * @returns an instance (or a clone) of the current node with its hiearchy
  14809. */
  14810. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14811. doNotInstantiate: boolean;
  14812. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14813. /**
  14814. * Prevents the World matrix to be computed any longer
  14815. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14816. * @returns the TransformNode.
  14817. */
  14818. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14819. /**
  14820. * Allows back the World matrix computation.
  14821. * @returns the TransformNode.
  14822. */
  14823. unfreezeWorldMatrix(): this;
  14824. /**
  14825. * True if the World matrix has been frozen.
  14826. */
  14827. get isWorldMatrixFrozen(): boolean;
  14828. /**
  14829. * Retuns the mesh absolute position in the World.
  14830. * @returns a Vector3.
  14831. */
  14832. getAbsolutePosition(): Vector3;
  14833. /**
  14834. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14835. * @param absolutePosition the absolute position to set
  14836. * @returns the TransformNode.
  14837. */
  14838. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14839. /**
  14840. * Sets the mesh position in its local space.
  14841. * @param vector3 the position to set in localspace
  14842. * @returns the TransformNode.
  14843. */
  14844. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14845. /**
  14846. * Returns the mesh position in the local space from the current World matrix values.
  14847. * @returns a new Vector3.
  14848. */
  14849. getPositionExpressedInLocalSpace(): Vector3;
  14850. /**
  14851. * Translates the mesh along the passed Vector3 in its local space.
  14852. * @param vector3 the distance to translate in localspace
  14853. * @returns the TransformNode.
  14854. */
  14855. locallyTranslate(vector3: Vector3): TransformNode;
  14856. private static _lookAtVectorCache;
  14857. /**
  14858. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14859. * @param targetPoint the position (must be in same space as current mesh) to look at
  14860. * @param yawCor optional yaw (y-axis) correction in radians
  14861. * @param pitchCor optional pitch (x-axis) correction in radians
  14862. * @param rollCor optional roll (z-axis) correction in radians
  14863. * @param space the choosen space of the target
  14864. * @returns the TransformNode.
  14865. */
  14866. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14867. /**
  14868. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14869. * This Vector3 is expressed in the World space.
  14870. * @param localAxis axis to rotate
  14871. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14872. */
  14873. getDirection(localAxis: Vector3): Vector3;
  14874. /**
  14875. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14876. * localAxis is expressed in the mesh local space.
  14877. * result is computed in the Wordl space from the mesh World matrix.
  14878. * @param localAxis axis to rotate
  14879. * @param result the resulting transformnode
  14880. * @returns this TransformNode.
  14881. */
  14882. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14883. /**
  14884. * Sets this transform node rotation to the given local axis.
  14885. * @param localAxis the axis in local space
  14886. * @param yawCor optional yaw (y-axis) correction in radians
  14887. * @param pitchCor optional pitch (x-axis) correction in radians
  14888. * @param rollCor optional roll (z-axis) correction in radians
  14889. * @returns this TransformNode
  14890. */
  14891. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14892. /**
  14893. * Sets a new pivot point to the current node
  14894. * @param point defines the new pivot point to use
  14895. * @param space defines if the point is in world or local space (local by default)
  14896. * @returns the current TransformNode
  14897. */
  14898. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14899. /**
  14900. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14901. * @returns the pivot point
  14902. */
  14903. getPivotPoint(): Vector3;
  14904. /**
  14905. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14906. * @param result the vector3 to store the result
  14907. * @returns this TransformNode.
  14908. */
  14909. getPivotPointToRef(result: Vector3): TransformNode;
  14910. /**
  14911. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14912. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14913. */
  14914. getAbsolutePivotPoint(): Vector3;
  14915. /**
  14916. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14917. * @param result vector3 to store the result
  14918. * @returns this TransformNode.
  14919. */
  14920. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14921. /**
  14922. * Defines the passed node as the parent of the current node.
  14923. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14924. * @see https://doc.babylonjs.com/how_to/parenting
  14925. * @param node the node ot set as the parent
  14926. * @returns this TransformNode.
  14927. */
  14928. setParent(node: Nullable<Node>): TransformNode;
  14929. private _nonUniformScaling;
  14930. /**
  14931. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14932. */
  14933. get nonUniformScaling(): boolean;
  14934. /** @hidden */
  14935. _updateNonUniformScalingState(value: boolean): boolean;
  14936. /**
  14937. * Attach the current TransformNode to another TransformNode associated with a bone
  14938. * @param bone Bone affecting the TransformNode
  14939. * @param affectedTransformNode TransformNode associated with the bone
  14940. * @returns this object
  14941. */
  14942. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14943. /**
  14944. * Detach the transform node if its associated with a bone
  14945. * @returns this object
  14946. */
  14947. detachFromBone(): TransformNode;
  14948. private static _rotationAxisCache;
  14949. /**
  14950. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14951. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14952. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14953. * The passed axis is also normalized.
  14954. * @param axis the axis to rotate around
  14955. * @param amount the amount to rotate in radians
  14956. * @param space Space to rotate in (Default: local)
  14957. * @returns the TransformNode.
  14958. */
  14959. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14960. /**
  14961. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14962. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14963. * The passed axis is also normalized. .
  14964. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14965. * @param point the point to rotate around
  14966. * @param axis the axis to rotate around
  14967. * @param amount the amount to rotate in radians
  14968. * @returns the TransformNode
  14969. */
  14970. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14971. /**
  14972. * Translates the mesh along the axis vector for the passed distance in the given space.
  14973. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14974. * @param axis the axis to translate in
  14975. * @param distance the distance to translate
  14976. * @param space Space to rotate in (Default: local)
  14977. * @returns the TransformNode.
  14978. */
  14979. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14980. /**
  14981. * Adds a rotation step to the mesh current rotation.
  14982. * x, y, z are Euler angles expressed in radians.
  14983. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14984. * This means this rotation is made in the mesh local space only.
  14985. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14986. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14987. * ```javascript
  14988. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14989. * ```
  14990. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14991. * 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.
  14992. * @param x Rotation to add
  14993. * @param y Rotation to add
  14994. * @param z Rotation to add
  14995. * @returns the TransformNode.
  14996. */
  14997. addRotation(x: number, y: number, z: number): TransformNode;
  14998. /**
  14999. * @hidden
  15000. */
  15001. protected _getEffectiveParent(): Nullable<Node>;
  15002. /**
  15003. * Computes the world matrix of the node
  15004. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15005. * @returns the world matrix
  15006. */
  15007. computeWorldMatrix(force?: boolean): Matrix;
  15008. /**
  15009. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15010. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15011. */
  15012. resetLocalMatrix(independentOfChildren?: boolean): void;
  15013. protected _afterComputeWorldMatrix(): void;
  15014. /**
  15015. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15016. * @param func callback function to add
  15017. *
  15018. * @returns the TransformNode.
  15019. */
  15020. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15021. /**
  15022. * Removes a registered callback function.
  15023. * @param func callback function to remove
  15024. * @returns the TransformNode.
  15025. */
  15026. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15027. /**
  15028. * Gets the position of the current mesh in camera space
  15029. * @param camera defines the camera to use
  15030. * @returns a position
  15031. */
  15032. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15033. /**
  15034. * Returns the distance from the mesh to the active camera
  15035. * @param camera defines the camera to use
  15036. * @returns the distance
  15037. */
  15038. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15039. /**
  15040. * Clone the current transform node
  15041. * @param name Name of the new clone
  15042. * @param newParent New parent for the clone
  15043. * @param doNotCloneChildren Do not clone children hierarchy
  15044. * @returns the new transform node
  15045. */
  15046. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15047. /**
  15048. * Serializes the objects information.
  15049. * @param currentSerializationObject defines the object to serialize in
  15050. * @returns the serialized object
  15051. */
  15052. serialize(currentSerializationObject?: any): any;
  15053. /**
  15054. * Returns a new TransformNode object parsed from the source provided.
  15055. * @param parsedTransformNode is the source.
  15056. * @param scene the scne the object belongs to
  15057. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15058. * @returns a new TransformNode object parsed from the source provided.
  15059. */
  15060. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15061. /**
  15062. * Get all child-transformNodes of this node
  15063. * @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
  15064. * @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
  15065. * @returns an array of TransformNode
  15066. */
  15067. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15068. /**
  15069. * Releases resources associated with this transform node.
  15070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15072. */
  15073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15074. /**
  15075. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15076. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15077. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15078. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15079. * @returns the current mesh
  15080. */
  15081. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15082. private _syncAbsoluteScalingAndRotation;
  15083. }
  15084. }
  15085. declare module BABYLON {
  15086. /**
  15087. * Class used to override all child animations of a given target
  15088. */
  15089. export class AnimationPropertiesOverride {
  15090. /**
  15091. * Gets or sets a value indicating if animation blending must be used
  15092. */
  15093. enableBlending: boolean;
  15094. /**
  15095. * Gets or sets the blending speed to use when enableBlending is true
  15096. */
  15097. blendingSpeed: number;
  15098. /**
  15099. * Gets or sets the default loop mode to use
  15100. */
  15101. loopMode: number;
  15102. }
  15103. }
  15104. declare module BABYLON {
  15105. /**
  15106. * Class used to store bone information
  15107. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15108. */
  15109. export class Bone extends Node {
  15110. /**
  15111. * defines the bone name
  15112. */
  15113. name: string;
  15114. private static _tmpVecs;
  15115. private static _tmpQuat;
  15116. private static _tmpMats;
  15117. /**
  15118. * Gets the list of child bones
  15119. */
  15120. children: Bone[];
  15121. /** Gets the animations associated with this bone */
  15122. animations: Animation[];
  15123. /**
  15124. * Gets or sets bone length
  15125. */
  15126. length: number;
  15127. /**
  15128. * @hidden Internal only
  15129. * Set this value to map this bone to a different index in the transform matrices
  15130. * Set this value to -1 to exclude the bone from the transform matrices
  15131. */
  15132. _index: Nullable<number>;
  15133. private _skeleton;
  15134. private _localMatrix;
  15135. private _restPose;
  15136. private _bindPose;
  15137. private _baseMatrix;
  15138. private _absoluteTransform;
  15139. private _invertedAbsoluteTransform;
  15140. private _parent;
  15141. private _scalingDeterminant;
  15142. private _worldTransform;
  15143. private _localScaling;
  15144. private _localRotation;
  15145. private _localPosition;
  15146. private _needToDecompose;
  15147. private _needToCompose;
  15148. /** @hidden */
  15149. _linkedTransformNode: Nullable<TransformNode>;
  15150. /** @hidden */
  15151. _waitingTransformNodeId: Nullable<string>;
  15152. /** @hidden */
  15153. get _matrix(): Matrix;
  15154. /** @hidden */
  15155. set _matrix(value: Matrix);
  15156. /**
  15157. * Create a new bone
  15158. * @param name defines the bone name
  15159. * @param skeleton defines the parent skeleton
  15160. * @param parentBone defines the parent (can be null if the bone is the root)
  15161. * @param localMatrix defines the local matrix
  15162. * @param restPose defines the rest pose matrix
  15163. * @param baseMatrix defines the base matrix
  15164. * @param index defines index of the bone in the hiearchy
  15165. */
  15166. constructor(
  15167. /**
  15168. * defines the bone name
  15169. */
  15170. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15171. /**
  15172. * Gets the current object class name.
  15173. * @return the class name
  15174. */
  15175. getClassName(): string;
  15176. /**
  15177. * Gets the parent skeleton
  15178. * @returns a skeleton
  15179. */
  15180. getSkeleton(): Skeleton;
  15181. /**
  15182. * Gets parent bone
  15183. * @returns a bone or null if the bone is the root of the bone hierarchy
  15184. */
  15185. getParent(): Nullable<Bone>;
  15186. /**
  15187. * Returns an array containing the root bones
  15188. * @returns an array containing the root bones
  15189. */
  15190. getChildren(): Array<Bone>;
  15191. /**
  15192. * Gets the node index in matrix array generated for rendering
  15193. * @returns the node index
  15194. */
  15195. getIndex(): number;
  15196. /**
  15197. * Sets the parent bone
  15198. * @param parent defines the parent (can be null if the bone is the root)
  15199. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15200. */
  15201. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15202. /**
  15203. * Gets the local matrix
  15204. * @returns a matrix
  15205. */
  15206. getLocalMatrix(): Matrix;
  15207. /**
  15208. * Gets the base matrix (initial matrix which remains unchanged)
  15209. * @returns a matrix
  15210. */
  15211. getBaseMatrix(): Matrix;
  15212. /**
  15213. * Gets the rest pose matrix
  15214. * @returns a matrix
  15215. */
  15216. getRestPose(): Matrix;
  15217. /**
  15218. * Sets the rest pose matrix
  15219. * @param matrix the local-space rest pose to set for this bone
  15220. */
  15221. setRestPose(matrix: Matrix): void;
  15222. /**
  15223. * Gets the bind pose matrix
  15224. * @returns the bind pose matrix
  15225. */
  15226. getBindPose(): Matrix;
  15227. /**
  15228. * Sets the bind pose matrix
  15229. * @param matrix the local-space bind pose to set for this bone
  15230. */
  15231. setBindPose(matrix: Matrix): void;
  15232. /**
  15233. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15234. */
  15235. getWorldMatrix(): Matrix;
  15236. /**
  15237. * Sets the local matrix to rest pose matrix
  15238. */
  15239. returnToRest(): void;
  15240. /**
  15241. * Gets the inverse of the absolute transform matrix.
  15242. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15243. * @returns a matrix
  15244. */
  15245. getInvertedAbsoluteTransform(): Matrix;
  15246. /**
  15247. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15248. * @returns a matrix
  15249. */
  15250. getAbsoluteTransform(): Matrix;
  15251. /**
  15252. * Links with the given transform node.
  15253. * The local matrix of this bone is copied from the transform node every frame.
  15254. * @param transformNode defines the transform node to link to
  15255. */
  15256. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15257. /**
  15258. * Gets the node used to drive the bone's transformation
  15259. * @returns a transform node or null
  15260. */
  15261. getTransformNode(): Nullable<TransformNode>;
  15262. /** Gets or sets current position (in local space) */
  15263. get position(): Vector3;
  15264. set position(newPosition: Vector3);
  15265. /** Gets or sets current rotation (in local space) */
  15266. get rotation(): Vector3;
  15267. set rotation(newRotation: Vector3);
  15268. /** Gets or sets current rotation quaternion (in local space) */
  15269. get rotationQuaternion(): Quaternion;
  15270. set rotationQuaternion(newRotation: Quaternion);
  15271. /** Gets or sets current scaling (in local space) */
  15272. get scaling(): Vector3;
  15273. set scaling(newScaling: Vector3);
  15274. /**
  15275. * Gets the animation properties override
  15276. */
  15277. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15278. private _decompose;
  15279. private _compose;
  15280. /**
  15281. * Update the base and local matrices
  15282. * @param matrix defines the new base or local matrix
  15283. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15284. * @param updateLocalMatrix defines if the local matrix should be updated
  15285. */
  15286. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15287. /** @hidden */
  15288. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15289. /**
  15290. * Flag the bone as dirty (Forcing it to update everything)
  15291. */
  15292. markAsDirty(): void;
  15293. /** @hidden */
  15294. _markAsDirtyAndCompose(): void;
  15295. private _markAsDirtyAndDecompose;
  15296. /**
  15297. * Translate the bone in local or world space
  15298. * @param vec The amount to translate the bone
  15299. * @param space The space that the translation is in
  15300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15301. */
  15302. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15303. /**
  15304. * Set the postion of the bone in local or world space
  15305. * @param position The position to set the bone
  15306. * @param space The space that the position is in
  15307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15308. */
  15309. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15310. /**
  15311. * Set the absolute position of the bone (world space)
  15312. * @param position The position to set the bone
  15313. * @param mesh The mesh that this bone is attached to
  15314. */
  15315. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15316. /**
  15317. * Scale the bone on the x, y and z axes (in local space)
  15318. * @param x The amount to scale the bone on the x axis
  15319. * @param y The amount to scale the bone on the y axis
  15320. * @param z The amount to scale the bone on the z axis
  15321. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15322. */
  15323. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15324. /**
  15325. * Set the bone scaling in local space
  15326. * @param scale defines the scaling vector
  15327. */
  15328. setScale(scale: Vector3): void;
  15329. /**
  15330. * Gets the current scaling in local space
  15331. * @returns the current scaling vector
  15332. */
  15333. getScale(): Vector3;
  15334. /**
  15335. * Gets the current scaling in local space and stores it in a target vector
  15336. * @param result defines the target vector
  15337. */
  15338. getScaleToRef(result: Vector3): void;
  15339. /**
  15340. * Set the yaw, pitch, and roll of the bone in local or world space
  15341. * @param yaw The rotation of the bone on the y axis
  15342. * @param pitch The rotation of the bone on the x axis
  15343. * @param roll The rotation of the bone on the z axis
  15344. * @param space The space that the axes of rotation are in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. */
  15347. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15348. /**
  15349. * Add a rotation to the bone on an axis in local or world space
  15350. * @param axis The axis to rotate the bone on
  15351. * @param amount The amount to rotate the bone
  15352. * @param space The space that the axis is in
  15353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15354. */
  15355. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15356. /**
  15357. * Set the rotation of the bone to a particular axis angle in local or world space
  15358. * @param axis The axis to rotate the bone on
  15359. * @param angle The angle that the bone should be rotated to
  15360. * @param space The space that the axis is in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. */
  15363. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15364. /**
  15365. * Set the euler rotation of the bone in local of world space
  15366. * @param rotation The euler rotation that the bone should be set to
  15367. * @param space The space that the rotation is in
  15368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15369. */
  15370. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15371. /**
  15372. * Set the quaternion rotation of the bone in local of world space
  15373. * @param quat The quaternion rotation that the bone should be set to
  15374. * @param space The space that the rotation is in
  15375. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15376. */
  15377. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15378. /**
  15379. * Set the rotation matrix of the bone in local of world space
  15380. * @param rotMat The rotation matrix that the bone should be set to
  15381. * @param space The space that the rotation is in
  15382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15383. */
  15384. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15385. private _rotateWithMatrix;
  15386. private _getNegativeRotationToRef;
  15387. /**
  15388. * Get the position of the bone in local or world space
  15389. * @param space The space that the returned position is in
  15390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15391. * @returns The position of the bone
  15392. */
  15393. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15394. /**
  15395. * Copy the position of the bone to a vector3 in local or world space
  15396. * @param space The space that the returned position is in
  15397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15398. * @param result The vector3 to copy the position to
  15399. */
  15400. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15401. /**
  15402. * Get the absolute position of the bone (world space)
  15403. * @param mesh The mesh that this bone is attached to
  15404. * @returns The absolute position of the bone
  15405. */
  15406. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15407. /**
  15408. * Copy the absolute position of the bone (world space) to the result param
  15409. * @param mesh The mesh that this bone is attached to
  15410. * @param result The vector3 to copy the absolute position to
  15411. */
  15412. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15413. /**
  15414. * Compute the absolute transforms of this bone and its children
  15415. */
  15416. computeAbsoluteTransforms(): void;
  15417. /**
  15418. * Get the world direction from an axis that is in the local space of the bone
  15419. * @param localAxis The local direction that is used to compute the world direction
  15420. * @param mesh The mesh that this bone is attached to
  15421. * @returns The world direction
  15422. */
  15423. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15424. /**
  15425. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15426. * @param localAxis The local direction that is used to compute the world direction
  15427. * @param mesh The mesh that this bone is attached to
  15428. * @param result The vector3 that the world direction will be copied to
  15429. */
  15430. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15431. /**
  15432. * Get the euler rotation of the bone in local or world space
  15433. * @param space The space that the rotation should be in
  15434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15435. * @returns The euler rotation
  15436. */
  15437. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15438. /**
  15439. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15440. * @param space The space that the rotation should be in
  15441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15442. * @param result The vector3 that the rotation should be copied to
  15443. */
  15444. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15445. /**
  15446. * Get the quaternion rotation of the bone in either local or world space
  15447. * @param space The space that the rotation should be in
  15448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15449. * @returns The quaternion rotation
  15450. */
  15451. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15452. /**
  15453. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15454. * @param space The space that the rotation should be in
  15455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15456. * @param result The quaternion that the rotation should be copied to
  15457. */
  15458. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15459. /**
  15460. * Get the rotation matrix of the bone in local or world space
  15461. * @param space The space that the rotation should be in
  15462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15463. * @returns The rotation matrix
  15464. */
  15465. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15466. /**
  15467. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15468. * @param space The space that the rotation should be in
  15469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15470. * @param result The quaternion that the rotation should be copied to
  15471. */
  15472. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15473. /**
  15474. * Get the world position of a point that is in the local space of the bone
  15475. * @param position The local position
  15476. * @param mesh The mesh that this bone is attached to
  15477. * @returns The world position
  15478. */
  15479. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15480. /**
  15481. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15482. * @param position The local position
  15483. * @param mesh The mesh that this bone is attached to
  15484. * @param result The vector3 that the world position should be copied to
  15485. */
  15486. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15487. /**
  15488. * Get the local position of a point that is in world space
  15489. * @param position The world position
  15490. * @param mesh The mesh that this bone is attached to
  15491. * @returns The local position
  15492. */
  15493. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15494. /**
  15495. * Get the local position of a point that is in world space and copy it to the result param
  15496. * @param position The world position
  15497. * @param mesh The mesh that this bone is attached to
  15498. * @param result The vector3 that the local position should be copied to
  15499. */
  15500. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15501. }
  15502. }
  15503. declare module BABYLON {
  15504. /**
  15505. * Defines a runtime animation
  15506. */
  15507. export class RuntimeAnimation {
  15508. private _events;
  15509. /**
  15510. * The current frame of the runtime animation
  15511. */
  15512. private _currentFrame;
  15513. /**
  15514. * The animation used by the runtime animation
  15515. */
  15516. private _animation;
  15517. /**
  15518. * The target of the runtime animation
  15519. */
  15520. private _target;
  15521. /**
  15522. * The initiating animatable
  15523. */
  15524. private _host;
  15525. /**
  15526. * The original value of the runtime animation
  15527. */
  15528. private _originalValue;
  15529. /**
  15530. * The original blend value of the runtime animation
  15531. */
  15532. private _originalBlendValue;
  15533. /**
  15534. * The offsets cache of the runtime animation
  15535. */
  15536. private _offsetsCache;
  15537. /**
  15538. * The high limits cache of the runtime animation
  15539. */
  15540. private _highLimitsCache;
  15541. /**
  15542. * Specifies if the runtime animation has been stopped
  15543. */
  15544. private _stopped;
  15545. /**
  15546. * The blending factor of the runtime animation
  15547. */
  15548. private _blendingFactor;
  15549. /**
  15550. * The BabylonJS scene
  15551. */
  15552. private _scene;
  15553. /**
  15554. * The current value of the runtime animation
  15555. */
  15556. private _currentValue;
  15557. /** @hidden */
  15558. _animationState: _IAnimationState;
  15559. /**
  15560. * The active target of the runtime animation
  15561. */
  15562. private _activeTargets;
  15563. private _currentActiveTarget;
  15564. private _directTarget;
  15565. /**
  15566. * The target path of the runtime animation
  15567. */
  15568. private _targetPath;
  15569. /**
  15570. * The weight of the runtime animation
  15571. */
  15572. private _weight;
  15573. /**
  15574. * The ratio offset of the runtime animation
  15575. */
  15576. private _ratioOffset;
  15577. /**
  15578. * The previous delay of the runtime animation
  15579. */
  15580. private _previousDelay;
  15581. /**
  15582. * The previous ratio of the runtime animation
  15583. */
  15584. private _previousRatio;
  15585. private _enableBlending;
  15586. private _keys;
  15587. private _minFrame;
  15588. private _maxFrame;
  15589. private _minValue;
  15590. private _maxValue;
  15591. private _targetIsArray;
  15592. /**
  15593. * Gets the current frame of the runtime animation
  15594. */
  15595. get currentFrame(): number;
  15596. /**
  15597. * Gets the weight of the runtime animation
  15598. */
  15599. get weight(): number;
  15600. /**
  15601. * Gets the current value of the runtime animation
  15602. */
  15603. get currentValue(): any;
  15604. /**
  15605. * Gets the target path of the runtime animation
  15606. */
  15607. get targetPath(): string;
  15608. /**
  15609. * Gets the actual target of the runtime animation
  15610. */
  15611. get target(): any;
  15612. /**
  15613. * Gets the additive state of the runtime animation
  15614. */
  15615. get isAdditive(): boolean;
  15616. /** @hidden */
  15617. _onLoop: () => void;
  15618. /**
  15619. * Create a new RuntimeAnimation object
  15620. * @param target defines the target of the animation
  15621. * @param animation defines the source animation object
  15622. * @param scene defines the hosting scene
  15623. * @param host defines the initiating Animatable
  15624. */
  15625. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15626. private _preparePath;
  15627. /**
  15628. * Gets the animation from the runtime animation
  15629. */
  15630. get animation(): Animation;
  15631. /**
  15632. * Resets the runtime animation to the beginning
  15633. * @param restoreOriginal defines whether to restore the target property to the original value
  15634. */
  15635. reset(restoreOriginal?: boolean): void;
  15636. /**
  15637. * Specifies if the runtime animation is stopped
  15638. * @returns Boolean specifying if the runtime animation is stopped
  15639. */
  15640. isStopped(): boolean;
  15641. /**
  15642. * Disposes of the runtime animation
  15643. */
  15644. dispose(): void;
  15645. /**
  15646. * Apply the interpolated value to the target
  15647. * @param currentValue defines the value computed by the animation
  15648. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15649. */
  15650. setValue(currentValue: any, weight: number): void;
  15651. private _getOriginalValues;
  15652. private _setValue;
  15653. /**
  15654. * Gets the loop pmode of the runtime animation
  15655. * @returns Loop Mode
  15656. */
  15657. private _getCorrectLoopMode;
  15658. /**
  15659. * Move the current animation to a given frame
  15660. * @param frame defines the frame to move to
  15661. */
  15662. goToFrame(frame: number): void;
  15663. /**
  15664. * @hidden Internal use only
  15665. */
  15666. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15667. /**
  15668. * Execute the current animation
  15669. * @param delay defines the delay to add to the current frame
  15670. * @param from defines the lower bound of the animation range
  15671. * @param to defines the upper bound of the animation range
  15672. * @param loop defines if the current animation must loop
  15673. * @param speedRatio defines the current speed ratio
  15674. * @param weight defines the weight of the animation (default is -1 so no weight)
  15675. * @param onLoop optional callback called when animation loops
  15676. * @returns a boolean indicating if the animation is running
  15677. */
  15678. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15679. }
  15680. }
  15681. declare module BABYLON {
  15682. /**
  15683. * Class used to store an actual running animation
  15684. */
  15685. export class Animatable {
  15686. /** defines the target object */
  15687. target: any;
  15688. /** defines the starting frame number (default is 0) */
  15689. fromFrame: number;
  15690. /** defines the ending frame number (default is 100) */
  15691. toFrame: number;
  15692. /** defines if the animation must loop (default is false) */
  15693. loopAnimation: boolean;
  15694. /** defines a callback to call when animation ends if it is not looping */
  15695. onAnimationEnd?: (() => void) | null | undefined;
  15696. /** defines a callback to call when animation loops */
  15697. onAnimationLoop?: (() => void) | null | undefined;
  15698. /** defines whether the animation should be evaluated additively */
  15699. isAdditive: boolean;
  15700. private _localDelayOffset;
  15701. private _pausedDelay;
  15702. private _runtimeAnimations;
  15703. private _paused;
  15704. private _scene;
  15705. private _speedRatio;
  15706. private _weight;
  15707. private _syncRoot;
  15708. /**
  15709. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15710. * This will only apply for non looping animation (default is true)
  15711. */
  15712. disposeOnEnd: boolean;
  15713. /**
  15714. * Gets a boolean indicating if the animation has started
  15715. */
  15716. animationStarted: boolean;
  15717. /**
  15718. * Observer raised when the animation ends
  15719. */
  15720. onAnimationEndObservable: Observable<Animatable>;
  15721. /**
  15722. * Observer raised when the animation loops
  15723. */
  15724. onAnimationLoopObservable: Observable<Animatable>;
  15725. /**
  15726. * Gets the root Animatable used to synchronize and normalize animations
  15727. */
  15728. get syncRoot(): Nullable<Animatable>;
  15729. /**
  15730. * Gets the current frame of the first RuntimeAnimation
  15731. * Used to synchronize Animatables
  15732. */
  15733. get masterFrame(): number;
  15734. /**
  15735. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15736. */
  15737. get weight(): number;
  15738. set weight(value: number);
  15739. /**
  15740. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15741. */
  15742. get speedRatio(): number;
  15743. set speedRatio(value: number);
  15744. /**
  15745. * Creates a new Animatable
  15746. * @param scene defines the hosting scene
  15747. * @param target defines the target object
  15748. * @param fromFrame defines the starting frame number (default is 0)
  15749. * @param toFrame defines the ending frame number (default is 100)
  15750. * @param loopAnimation defines if the animation must loop (default is false)
  15751. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15752. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15753. * @param animations defines a group of animation to add to the new Animatable
  15754. * @param onAnimationLoop defines a callback to call when animation loops
  15755. * @param isAdditive defines whether the animation should be evaluated additively
  15756. */
  15757. constructor(scene: Scene,
  15758. /** defines the target object */
  15759. target: any,
  15760. /** defines the starting frame number (default is 0) */
  15761. fromFrame?: number,
  15762. /** defines the ending frame number (default is 100) */
  15763. toFrame?: number,
  15764. /** defines if the animation must loop (default is false) */
  15765. loopAnimation?: boolean, speedRatio?: number,
  15766. /** defines a callback to call when animation ends if it is not looping */
  15767. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15768. /** defines a callback to call when animation loops */
  15769. onAnimationLoop?: (() => void) | null | undefined,
  15770. /** defines whether the animation should be evaluated additively */
  15771. isAdditive?: boolean);
  15772. /**
  15773. * Synchronize and normalize current Animatable with a source Animatable
  15774. * This is useful when using animation weights and when animations are not of the same length
  15775. * @param root defines the root Animatable to synchronize with
  15776. * @returns the current Animatable
  15777. */
  15778. syncWith(root: Animatable): Animatable;
  15779. /**
  15780. * Gets the list of runtime animations
  15781. * @returns an array of RuntimeAnimation
  15782. */
  15783. getAnimations(): RuntimeAnimation[];
  15784. /**
  15785. * Adds more animations to the current animatable
  15786. * @param target defines the target of the animations
  15787. * @param animations defines the new animations to add
  15788. */
  15789. appendAnimations(target: any, animations: Animation[]): void;
  15790. /**
  15791. * Gets the source animation for a specific property
  15792. * @param property defines the propertyu to look for
  15793. * @returns null or the source animation for the given property
  15794. */
  15795. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15796. /**
  15797. * Gets the runtime animation for a specific property
  15798. * @param property defines the propertyu to look for
  15799. * @returns null or the runtime animation for the given property
  15800. */
  15801. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15802. /**
  15803. * Resets the animatable to its original state
  15804. */
  15805. reset(): void;
  15806. /**
  15807. * Allows the animatable to blend with current running animations
  15808. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15809. * @param blendingSpeed defines the blending speed to use
  15810. */
  15811. enableBlending(blendingSpeed: number): void;
  15812. /**
  15813. * Disable animation blending
  15814. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15815. */
  15816. disableBlending(): void;
  15817. /**
  15818. * Jump directly to a given frame
  15819. * @param frame defines the frame to jump to
  15820. */
  15821. goToFrame(frame: number): void;
  15822. /**
  15823. * Pause the animation
  15824. */
  15825. pause(): void;
  15826. /**
  15827. * Restart the animation
  15828. */
  15829. restart(): void;
  15830. private _raiseOnAnimationEnd;
  15831. /**
  15832. * Stop and delete the current animation
  15833. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15834. * @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)
  15835. */
  15836. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15837. /**
  15838. * Wait asynchronously for the animation to end
  15839. * @returns a promise which will be fullfilled when the animation ends
  15840. */
  15841. waitAsync(): Promise<Animatable>;
  15842. /** @hidden */
  15843. _animate(delay: number): boolean;
  15844. }
  15845. interface Scene {
  15846. /** @hidden */
  15847. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15848. /** @hidden */
  15849. _processLateAnimationBindingsForMatrices(holder: {
  15850. totalWeight: number;
  15851. totalAdditiveWeight: number;
  15852. animations: RuntimeAnimation[];
  15853. additiveAnimations: RuntimeAnimation[];
  15854. originalValue: Matrix;
  15855. }): any;
  15856. /** @hidden */
  15857. _processLateAnimationBindingsForQuaternions(holder: {
  15858. totalWeight: number;
  15859. totalAdditiveWeight: number;
  15860. animations: RuntimeAnimation[];
  15861. additiveAnimations: RuntimeAnimation[];
  15862. originalValue: Quaternion;
  15863. }, refQuaternion: Quaternion): Quaternion;
  15864. /** @hidden */
  15865. _processLateAnimationBindings(): void;
  15866. /**
  15867. * Will start the animation sequence of a given target
  15868. * @param target defines the target
  15869. * @param from defines from which frame should animation start
  15870. * @param to defines until which frame should animation run.
  15871. * @param weight defines the weight to apply to the animation (1.0 by default)
  15872. * @param loop defines if the animation loops
  15873. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15874. * @param onAnimationEnd defines the function to be executed when the animation ends
  15875. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15876. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15877. * @param onAnimationLoop defines the callback to call when an animation loops
  15878. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15879. * @returns the animatable object created for this animation
  15880. */
  15881. 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;
  15882. /**
  15883. * Will start the animation sequence of a given target
  15884. * @param target defines the target
  15885. * @param from defines from which frame should animation start
  15886. * @param to defines until which frame should animation run.
  15887. * @param loop defines if the animation loops
  15888. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15889. * @param onAnimationEnd defines the function to be executed when the animation ends
  15890. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15891. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15892. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15893. * @param onAnimationLoop defines the callback to call when an animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15895. * @returns the animatable object created for this animation
  15896. */
  15897. 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;
  15898. /**
  15899. * Will start the animation sequence of a given target and its hierarchy
  15900. * @param target defines the target
  15901. * @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.
  15902. * @param from defines from which frame should animation start
  15903. * @param to defines until which frame should animation run.
  15904. * @param loop defines if the animation loops
  15905. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15906. * @param onAnimationEnd defines the function to be executed when the animation ends
  15907. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15908. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15909. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15910. * @param onAnimationLoop defines the callback to call when an animation loops
  15911. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15912. * @returns the list of created animatables
  15913. */
  15914. 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[];
  15915. /**
  15916. * Begin a new animation on a given node
  15917. * @param target defines the target where the animation will take place
  15918. * @param animations defines the list of animations to start
  15919. * @param from defines the initial value
  15920. * @param to defines the final value
  15921. * @param loop defines if you want animation to loop (off by default)
  15922. * @param speedRatio defines the speed ratio to apply to all animations
  15923. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15924. * @param onAnimationLoop defines the callback to call when an animation loops
  15925. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15926. * @returns the list of created animatables
  15927. */
  15928. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15929. /**
  15930. * Begin a new animation on a given node and its hierarchy
  15931. * @param target defines the root node where the animation will take place
  15932. * @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.
  15933. * @param animations defines the list of animations to start
  15934. * @param from defines the initial value
  15935. * @param to defines the final value
  15936. * @param loop defines if you want animation to loop (off by default)
  15937. * @param speedRatio defines the speed ratio to apply to all animations
  15938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15939. * @param onAnimationLoop defines the callback to call when an animation loops
  15940. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15941. * @returns the list of animatables created for all nodes
  15942. */
  15943. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15944. /**
  15945. * Gets the animatable associated with a specific target
  15946. * @param target defines the target of the animatable
  15947. * @returns the required animatable if found
  15948. */
  15949. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15950. /**
  15951. * Gets all animatables associated with a given target
  15952. * @param target defines the target to look animatables for
  15953. * @returns an array of Animatables
  15954. */
  15955. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15956. /**
  15957. * Stops and removes all animations that have been applied to the scene
  15958. */
  15959. stopAllAnimations(): void;
  15960. /**
  15961. * Gets the current delta time used by animation engine
  15962. */
  15963. deltaTime: number;
  15964. }
  15965. interface Bone {
  15966. /**
  15967. * Copy an animation range from another bone
  15968. * @param source defines the source bone
  15969. * @param rangeName defines the range name to copy
  15970. * @param frameOffset defines the frame offset
  15971. * @param rescaleAsRequired defines if rescaling must be applied if required
  15972. * @param skelDimensionsRatio defines the scaling ratio
  15973. * @returns true if operation was successful
  15974. */
  15975. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15976. }
  15977. }
  15978. declare module BABYLON {
  15979. /**
  15980. * Class used to handle skinning animations
  15981. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15982. */
  15983. export class Skeleton implements IAnimatable {
  15984. /** defines the skeleton name */
  15985. name: string;
  15986. /** defines the skeleton Id */
  15987. id: string;
  15988. /**
  15989. * Defines the list of child bones
  15990. */
  15991. bones: Bone[];
  15992. /**
  15993. * Defines an estimate of the dimension of the skeleton at rest
  15994. */
  15995. dimensionsAtRest: Vector3;
  15996. /**
  15997. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15998. */
  15999. needInitialSkinMatrix: boolean;
  16000. /**
  16001. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16002. */
  16003. overrideMesh: Nullable<AbstractMesh>;
  16004. /**
  16005. * Gets the list of animations attached to this skeleton
  16006. */
  16007. animations: Array<Animation>;
  16008. private _scene;
  16009. private _isDirty;
  16010. private _transformMatrices;
  16011. private _transformMatrixTexture;
  16012. private _meshesWithPoseMatrix;
  16013. private _animatables;
  16014. private _identity;
  16015. private _synchronizedWithMesh;
  16016. private _ranges;
  16017. private _lastAbsoluteTransformsUpdateId;
  16018. private _canUseTextureForBones;
  16019. private _uniqueId;
  16020. /** @hidden */
  16021. _numBonesWithLinkedTransformNode: number;
  16022. /** @hidden */
  16023. _hasWaitingData: Nullable<boolean>;
  16024. /** @hidden */
  16025. _waitingOverrideMeshId: Nullable<string>;
  16026. /**
  16027. * Specifies if the skeleton should be serialized
  16028. */
  16029. doNotSerialize: boolean;
  16030. private _useTextureToStoreBoneMatrices;
  16031. /**
  16032. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16033. * Please note that this option is not available if the hardware does not support it
  16034. */
  16035. get useTextureToStoreBoneMatrices(): boolean;
  16036. set useTextureToStoreBoneMatrices(value: boolean);
  16037. private _animationPropertiesOverride;
  16038. /**
  16039. * Gets or sets the animation properties override
  16040. */
  16041. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16042. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16043. /**
  16044. * List of inspectable custom properties (used by the Inspector)
  16045. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16046. */
  16047. inspectableCustomProperties: IInspectable[];
  16048. /**
  16049. * An observable triggered before computing the skeleton's matrices
  16050. */
  16051. onBeforeComputeObservable: Observable<Skeleton>;
  16052. /**
  16053. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16054. */
  16055. get isUsingTextureForMatrices(): boolean;
  16056. /**
  16057. * Gets the unique ID of this skeleton
  16058. */
  16059. get uniqueId(): number;
  16060. /**
  16061. * Creates a new skeleton
  16062. * @param name defines the skeleton name
  16063. * @param id defines the skeleton Id
  16064. * @param scene defines the hosting scene
  16065. */
  16066. constructor(
  16067. /** defines the skeleton name */
  16068. name: string,
  16069. /** defines the skeleton Id */
  16070. id: string, scene: Scene);
  16071. /**
  16072. * Gets the current object class name.
  16073. * @return the class name
  16074. */
  16075. getClassName(): string;
  16076. /**
  16077. * Returns an array containing the root bones
  16078. * @returns an array containing the root bones
  16079. */
  16080. getChildren(): Array<Bone>;
  16081. /**
  16082. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16083. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16084. * @returns a Float32Array containing matrices data
  16085. */
  16086. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16087. /**
  16088. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16089. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16090. * @returns a raw texture containing the data
  16091. */
  16092. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16093. /**
  16094. * Gets the current hosting scene
  16095. * @returns a scene object
  16096. */
  16097. getScene(): Scene;
  16098. /**
  16099. * Gets a string representing the current skeleton data
  16100. * @param fullDetails defines a boolean indicating if we want a verbose version
  16101. * @returns a string representing the current skeleton data
  16102. */
  16103. toString(fullDetails?: boolean): string;
  16104. /**
  16105. * Get bone's index searching by name
  16106. * @param name defines bone's name to search for
  16107. * @return the indice of the bone. Returns -1 if not found
  16108. */
  16109. getBoneIndexByName(name: string): number;
  16110. /**
  16111. * Creater a new animation range
  16112. * @param name defines the name of the range
  16113. * @param from defines the start key
  16114. * @param to defines the end key
  16115. */
  16116. createAnimationRange(name: string, from: number, to: number): void;
  16117. /**
  16118. * Delete a specific animation range
  16119. * @param name defines the name of the range
  16120. * @param deleteFrames defines if frames must be removed as well
  16121. */
  16122. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16123. /**
  16124. * Gets a specific animation range
  16125. * @param name defines the name of the range to look for
  16126. * @returns the requested animation range or null if not found
  16127. */
  16128. getAnimationRange(name: string): Nullable<AnimationRange>;
  16129. /**
  16130. * Gets the list of all animation ranges defined on this skeleton
  16131. * @returns an array
  16132. */
  16133. getAnimationRanges(): Nullable<AnimationRange>[];
  16134. /**
  16135. * Copy animation range from a source skeleton.
  16136. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16137. * @param source defines the source skeleton
  16138. * @param name defines the name of the range to copy
  16139. * @param rescaleAsRequired defines if rescaling must be applied if required
  16140. * @returns true if operation was successful
  16141. */
  16142. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16143. /**
  16144. * Forces the skeleton to go to rest pose
  16145. */
  16146. returnToRest(): void;
  16147. private _getHighestAnimationFrame;
  16148. /**
  16149. * Begin a specific animation range
  16150. * @param name defines the name of the range to start
  16151. * @param loop defines if looping must be turned on (false by default)
  16152. * @param speedRatio defines the speed ratio to apply (1 by default)
  16153. * @param onAnimationEnd defines a callback which will be called when animation will end
  16154. * @returns a new animatable
  16155. */
  16156. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16157. /**
  16158. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16159. * @param skeleton defines the Skeleton containing the animation range to convert
  16160. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16161. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16162. * @returns the original skeleton
  16163. */
  16164. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16165. /** @hidden */
  16166. _markAsDirty(): void;
  16167. /** @hidden */
  16168. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16169. /** @hidden */
  16170. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16171. private _computeTransformMatrices;
  16172. /**
  16173. * Build all resources required to render a skeleton
  16174. */
  16175. prepare(): void;
  16176. /**
  16177. * Gets the list of animatables currently running for this skeleton
  16178. * @returns an array of animatables
  16179. */
  16180. getAnimatables(): IAnimatable[];
  16181. /**
  16182. * Clone the current skeleton
  16183. * @param name defines the name of the new skeleton
  16184. * @param id defines the id of the new skeleton
  16185. * @returns the new skeleton
  16186. */
  16187. clone(name: string, id?: string): Skeleton;
  16188. /**
  16189. * Enable animation blending for this skeleton
  16190. * @param blendingSpeed defines the blending speed to apply
  16191. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16192. */
  16193. enableBlending(blendingSpeed?: number): void;
  16194. /**
  16195. * Releases all resources associated with the current skeleton
  16196. */
  16197. dispose(): void;
  16198. /**
  16199. * Serialize the skeleton in a JSON object
  16200. * @returns a JSON object
  16201. */
  16202. serialize(): any;
  16203. /**
  16204. * Creates a new skeleton from serialized data
  16205. * @param parsedSkeleton defines the serialized data
  16206. * @param scene defines the hosting scene
  16207. * @returns a new skeleton
  16208. */
  16209. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16210. /**
  16211. * Compute all node absolute transforms
  16212. * @param forceUpdate defines if computation must be done even if cache is up to date
  16213. */
  16214. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16215. /**
  16216. * Gets the root pose matrix
  16217. * @returns a matrix
  16218. */
  16219. getPoseMatrix(): Nullable<Matrix>;
  16220. /**
  16221. * Sorts bones per internal index
  16222. */
  16223. sortBones(): void;
  16224. private _sortBones;
  16225. }
  16226. }
  16227. declare module BABYLON {
  16228. /**
  16229. * Creates an instance based on a source mesh.
  16230. */
  16231. export class InstancedMesh extends AbstractMesh {
  16232. private _sourceMesh;
  16233. private _currentLOD;
  16234. /** @hidden */
  16235. _indexInSourceMeshInstanceArray: number;
  16236. constructor(name: string, source: Mesh);
  16237. /**
  16238. * Returns the string "InstancedMesh".
  16239. */
  16240. getClassName(): string;
  16241. /** Gets the list of lights affecting that mesh */
  16242. get lightSources(): Light[];
  16243. _resyncLightSources(): void;
  16244. _resyncLightSource(light: Light): void;
  16245. _removeLightSource(light: Light, dispose: boolean): void;
  16246. /**
  16247. * If the source mesh receives shadows
  16248. */
  16249. get receiveShadows(): boolean;
  16250. /**
  16251. * The material of the source mesh
  16252. */
  16253. get material(): Nullable<Material>;
  16254. /**
  16255. * Visibility of the source mesh
  16256. */
  16257. get visibility(): number;
  16258. /**
  16259. * Skeleton of the source mesh
  16260. */
  16261. get skeleton(): Nullable<Skeleton>;
  16262. /**
  16263. * Rendering ground id of the source mesh
  16264. */
  16265. get renderingGroupId(): number;
  16266. set renderingGroupId(value: number);
  16267. /**
  16268. * Returns the total number of vertices (integer).
  16269. */
  16270. getTotalVertices(): number;
  16271. /**
  16272. * Returns a positive integer : the total number of indices in this mesh geometry.
  16273. * @returns the numner of indices or zero if the mesh has no geometry.
  16274. */
  16275. getTotalIndices(): number;
  16276. /**
  16277. * The source mesh of the instance
  16278. */
  16279. get sourceMesh(): Mesh;
  16280. /**
  16281. * Creates a new InstancedMesh object from the mesh model.
  16282. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16283. * @param name defines the name of the new instance
  16284. * @returns a new InstancedMesh
  16285. */
  16286. createInstance(name: string): InstancedMesh;
  16287. /**
  16288. * Is this node ready to be used/rendered
  16289. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16290. * @return {boolean} is it ready
  16291. */
  16292. isReady(completeCheck?: boolean): boolean;
  16293. /**
  16294. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16295. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16296. * @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.
  16297. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16298. */
  16299. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16300. /**
  16301. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16302. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16303. * The `data` are either a numeric array either a Float32Array.
  16304. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16305. * 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).
  16306. * Note that a new underlying VertexBuffer object is created each call.
  16307. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16308. *
  16309. * Possible `kind` values :
  16310. * - VertexBuffer.PositionKind
  16311. * - VertexBuffer.UVKind
  16312. * - VertexBuffer.UV2Kind
  16313. * - VertexBuffer.UV3Kind
  16314. * - VertexBuffer.UV4Kind
  16315. * - VertexBuffer.UV5Kind
  16316. * - VertexBuffer.UV6Kind
  16317. * - VertexBuffer.ColorKind
  16318. * - VertexBuffer.MatricesIndicesKind
  16319. * - VertexBuffer.MatricesIndicesExtraKind
  16320. * - VertexBuffer.MatricesWeightsKind
  16321. * - VertexBuffer.MatricesWeightsExtraKind
  16322. *
  16323. * Returns the Mesh.
  16324. */
  16325. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16326. /**
  16327. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16328. * If the mesh has no geometry, it is simply returned as it is.
  16329. * The `data` are either a numeric array either a Float32Array.
  16330. * No new underlying VertexBuffer object is created.
  16331. * 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.
  16332. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16333. *
  16334. * Possible `kind` values :
  16335. * - VertexBuffer.PositionKind
  16336. * - VertexBuffer.UVKind
  16337. * - VertexBuffer.UV2Kind
  16338. * - VertexBuffer.UV3Kind
  16339. * - VertexBuffer.UV4Kind
  16340. * - VertexBuffer.UV5Kind
  16341. * - VertexBuffer.UV6Kind
  16342. * - VertexBuffer.ColorKind
  16343. * - VertexBuffer.MatricesIndicesKind
  16344. * - VertexBuffer.MatricesIndicesExtraKind
  16345. * - VertexBuffer.MatricesWeightsKind
  16346. * - VertexBuffer.MatricesWeightsExtraKind
  16347. *
  16348. * Returns the Mesh.
  16349. */
  16350. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16351. /**
  16352. * Sets the mesh indices.
  16353. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16354. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16355. * This method creates a new index buffer each call.
  16356. * Returns the Mesh.
  16357. */
  16358. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16359. /**
  16360. * Boolean : True if the mesh owns the requested kind of data.
  16361. */
  16362. isVerticesDataPresent(kind: string): boolean;
  16363. /**
  16364. * Returns an array of indices (IndicesArray).
  16365. */
  16366. getIndices(): Nullable<IndicesArray>;
  16367. get _positions(): Nullable<Vector3[]>;
  16368. /**
  16369. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16370. * This means the mesh underlying bounding box and sphere are recomputed.
  16371. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16372. * @returns the current mesh
  16373. */
  16374. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16375. /** @hidden */
  16376. _preActivate(): InstancedMesh;
  16377. /** @hidden */
  16378. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16379. /** @hidden */
  16380. _postActivate(): void;
  16381. getWorldMatrix(): Matrix;
  16382. get isAnInstance(): boolean;
  16383. /**
  16384. * Returns the current associated LOD AbstractMesh.
  16385. */
  16386. getLOD(camera: Camera): AbstractMesh;
  16387. /** @hidden */
  16388. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16389. /** @hidden */
  16390. _syncSubMeshes(): InstancedMesh;
  16391. /** @hidden */
  16392. _generatePointsArray(): boolean;
  16393. /** @hidden */
  16394. _updateBoundingInfo(): AbstractMesh;
  16395. /**
  16396. * Creates a new InstancedMesh from the current mesh.
  16397. * - name (string) : the cloned mesh name
  16398. * - newParent (optional Node) : the optional Node to parent the clone to.
  16399. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16400. *
  16401. * Returns the clone.
  16402. */
  16403. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16404. /**
  16405. * Disposes the InstancedMesh.
  16406. * Returns nothing.
  16407. */
  16408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16409. }
  16410. interface Mesh {
  16411. /**
  16412. * Register a custom buffer that will be instanced
  16413. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16414. * @param kind defines the buffer kind
  16415. * @param stride defines the stride in floats
  16416. */
  16417. registerInstancedBuffer(kind: string, stride: number): void;
  16418. /**
  16419. * true to use the edge renderer for all instances of this mesh
  16420. */
  16421. edgesShareWithInstances: boolean;
  16422. /** @hidden */
  16423. _userInstancedBuffersStorage: {
  16424. data: {
  16425. [key: string]: Float32Array;
  16426. };
  16427. sizes: {
  16428. [key: string]: number;
  16429. };
  16430. vertexBuffers: {
  16431. [key: string]: Nullable<VertexBuffer>;
  16432. };
  16433. strides: {
  16434. [key: string]: number;
  16435. };
  16436. };
  16437. }
  16438. interface AbstractMesh {
  16439. /**
  16440. * Object used to store instanced buffers defined by user
  16441. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16442. */
  16443. instancedBuffers: {
  16444. [key: string]: any;
  16445. };
  16446. }
  16447. }
  16448. declare module BABYLON {
  16449. /**
  16450. * Defines the options associated with the creation of a shader material.
  16451. */
  16452. export interface IShaderMaterialOptions {
  16453. /**
  16454. * Does the material work in alpha blend mode
  16455. */
  16456. needAlphaBlending: boolean;
  16457. /**
  16458. * Does the material work in alpha test mode
  16459. */
  16460. needAlphaTesting: boolean;
  16461. /**
  16462. * The list of attribute names used in the shader
  16463. */
  16464. attributes: string[];
  16465. /**
  16466. * The list of unifrom names used in the shader
  16467. */
  16468. uniforms: string[];
  16469. /**
  16470. * The list of UBO names used in the shader
  16471. */
  16472. uniformBuffers: string[];
  16473. /**
  16474. * The list of sampler names used in the shader
  16475. */
  16476. samplers: string[];
  16477. /**
  16478. * The list of defines used in the shader
  16479. */
  16480. defines: string[];
  16481. }
  16482. /**
  16483. * 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.
  16484. *
  16485. * This returned material effects how the mesh will look based on the code in the shaders.
  16486. *
  16487. * @see https://doc.babylonjs.com/how_to/shader_material
  16488. */
  16489. export class ShaderMaterial extends Material {
  16490. private _shaderPath;
  16491. private _options;
  16492. private _textures;
  16493. private _textureArrays;
  16494. private _floats;
  16495. private _ints;
  16496. private _floatsArrays;
  16497. private _colors3;
  16498. private _colors3Arrays;
  16499. private _colors4;
  16500. private _colors4Arrays;
  16501. private _vectors2;
  16502. private _vectors3;
  16503. private _vectors4;
  16504. private _matrices;
  16505. private _matrixArrays;
  16506. private _matrices3x3;
  16507. private _matrices2x2;
  16508. private _vectors2Arrays;
  16509. private _vectors3Arrays;
  16510. private _vectors4Arrays;
  16511. private _cachedWorldViewMatrix;
  16512. private _cachedWorldViewProjectionMatrix;
  16513. private _renderId;
  16514. private _multiview;
  16515. private _cachedDefines;
  16516. /** Define the Url to load snippets */
  16517. static SnippetUrl: string;
  16518. /** Snippet ID if the material was created from the snippet server */
  16519. snippetId: string;
  16520. /**
  16521. * Instantiate a new shader material.
  16522. * 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.
  16523. * This returned material effects how the mesh will look based on the code in the shaders.
  16524. * @see https://doc.babylonjs.com/how_to/shader_material
  16525. * @param name Define the name of the material in the scene
  16526. * @param scene Define the scene the material belongs to
  16527. * @param shaderPath Defines the route to the shader code in one of three ways:
  16528. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16529. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16530. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16531. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16532. * @param options Define the options used to create the shader
  16533. */
  16534. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16535. /**
  16536. * Gets the shader path used to define the shader code
  16537. * It can be modified to trigger a new compilation
  16538. */
  16539. get shaderPath(): any;
  16540. /**
  16541. * Sets the shader path used to define the shader code
  16542. * It can be modified to trigger a new compilation
  16543. */
  16544. set shaderPath(shaderPath: any);
  16545. /**
  16546. * Gets the options used to compile the shader.
  16547. * They can be modified to trigger a new compilation
  16548. */
  16549. get options(): IShaderMaterialOptions;
  16550. /**
  16551. * Gets the current class name of the material e.g. "ShaderMaterial"
  16552. * Mainly use in serialization.
  16553. * @returns the class name
  16554. */
  16555. getClassName(): string;
  16556. /**
  16557. * Specifies if the material will require alpha blending
  16558. * @returns a boolean specifying if alpha blending is needed
  16559. */
  16560. needAlphaBlending(): boolean;
  16561. /**
  16562. * Specifies if this material should be rendered in alpha test mode
  16563. * @returns a boolean specifying if an alpha test is needed.
  16564. */
  16565. needAlphaTesting(): boolean;
  16566. private _checkUniform;
  16567. /**
  16568. * Set a texture in the shader.
  16569. * @param name Define the name of the uniform samplers as defined in the shader
  16570. * @param texture Define the texture to bind to this sampler
  16571. * @return the material itself allowing "fluent" like uniform updates
  16572. */
  16573. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16574. /**
  16575. * Set a texture array in the shader.
  16576. * @param name Define the name of the uniform sampler array as defined in the shader
  16577. * @param textures Define the list of textures to bind to this sampler
  16578. * @return the material itself allowing "fluent" like uniform updates
  16579. */
  16580. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16581. /**
  16582. * Set a float in the shader.
  16583. * @param name Define the name of the uniform as defined in the shader
  16584. * @param value Define the value to give to the uniform
  16585. * @return the material itself allowing "fluent" like uniform updates
  16586. */
  16587. setFloat(name: string, value: number): ShaderMaterial;
  16588. /**
  16589. * Set a int in the shader.
  16590. * @param name Define the name of the uniform as defined in the shader
  16591. * @param value Define the value to give to the uniform
  16592. * @return the material itself allowing "fluent" like uniform updates
  16593. */
  16594. setInt(name: string, value: number): ShaderMaterial;
  16595. /**
  16596. * Set an array of floats in the shader.
  16597. * @param name Define the name of the uniform as defined in the shader
  16598. * @param value Define the value to give to the uniform
  16599. * @return the material itself allowing "fluent" like uniform updates
  16600. */
  16601. setFloats(name: string, value: number[]): ShaderMaterial;
  16602. /**
  16603. * Set a vec3 in the shader from a Color3.
  16604. * @param name Define the name of the uniform as defined in the shader
  16605. * @param value Define the value to give to the uniform
  16606. * @return the material itself allowing "fluent" like uniform updates
  16607. */
  16608. setColor3(name: string, value: Color3): ShaderMaterial;
  16609. /**
  16610. * Set a vec3 array in the shader from a Color3 array.
  16611. * @param name Define the name of the uniform as defined in the shader
  16612. * @param value Define the value to give to the uniform
  16613. * @return the material itself allowing "fluent" like uniform updates
  16614. */
  16615. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16616. /**
  16617. * Set a vec4 in the shader from a Color4.
  16618. * @param name Define the name of the uniform as defined in the shader
  16619. * @param value Define the value to give to the uniform
  16620. * @return the material itself allowing "fluent" like uniform updates
  16621. */
  16622. setColor4(name: string, value: Color4): ShaderMaterial;
  16623. /**
  16624. * Set a vec4 array in the shader from a Color4 array.
  16625. * @param name Define the name of the uniform as defined in the shader
  16626. * @param value Define the value to give to the uniform
  16627. * @return the material itself allowing "fluent" like uniform updates
  16628. */
  16629. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16630. /**
  16631. * Set a vec2 in the shader from a Vector2.
  16632. * @param name Define the name of the uniform as defined in the shader
  16633. * @param value Define the value to give to the uniform
  16634. * @return the material itself allowing "fluent" like uniform updates
  16635. */
  16636. setVector2(name: string, value: Vector2): ShaderMaterial;
  16637. /**
  16638. * Set a vec3 in the shader from a Vector3.
  16639. * @param name Define the name of the uniform as defined in the shader
  16640. * @param value Define the value to give to the uniform
  16641. * @return the material itself allowing "fluent" like uniform updates
  16642. */
  16643. setVector3(name: string, value: Vector3): ShaderMaterial;
  16644. /**
  16645. * Set a vec4 in the shader from a Vector4.
  16646. * @param name Define the name of the uniform as defined in the shader
  16647. * @param value Define the value to give to the uniform
  16648. * @return the material itself allowing "fluent" like uniform updates
  16649. */
  16650. setVector4(name: string, value: Vector4): ShaderMaterial;
  16651. /**
  16652. * Set a mat4 in the shader from a Matrix.
  16653. * @param name Define the name of the uniform as defined in the shader
  16654. * @param value Define the value to give to the uniform
  16655. * @return the material itself allowing "fluent" like uniform updates
  16656. */
  16657. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16658. /**
  16659. * Set a float32Array in the shader from a matrix array.
  16660. * @param name Define the name of the uniform as defined in the shader
  16661. * @param value Define the value to give to the uniform
  16662. * @return the material itself allowing "fluent" like uniform updates
  16663. */
  16664. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16665. /**
  16666. * Set a mat3 in the shader from a Float32Array.
  16667. * @param name Define the name of the uniform as defined in the shader
  16668. * @param value Define the value to give to the uniform
  16669. * @return the material itself allowing "fluent" like uniform updates
  16670. */
  16671. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16672. /**
  16673. * Set a mat2 in the shader from a Float32Array.
  16674. * @param name Define the name of the uniform as defined in the shader
  16675. * @param value Define the value to give to the uniform
  16676. * @return the material itself allowing "fluent" like uniform updates
  16677. */
  16678. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16679. /**
  16680. * Set a vec2 array in the shader from a number array.
  16681. * @param name Define the name of the uniform as defined in the shader
  16682. * @param value Define the value to give to the uniform
  16683. * @return the material itself allowing "fluent" like uniform updates
  16684. */
  16685. setArray2(name: string, value: number[]): ShaderMaterial;
  16686. /**
  16687. * Set a vec3 array in the shader from a number array.
  16688. * @param name Define the name of the uniform as defined in the shader
  16689. * @param value Define the value to give to the uniform
  16690. * @return the material itself allowing "fluent" like uniform updates
  16691. */
  16692. setArray3(name: string, value: number[]): ShaderMaterial;
  16693. /**
  16694. * Set a vec4 array in the shader from a number array.
  16695. * @param name Define the name of the uniform as defined in the shader
  16696. * @param value Define the value to give to the uniform
  16697. * @return the material itself allowing "fluent" like uniform updates
  16698. */
  16699. setArray4(name: string, value: number[]): ShaderMaterial;
  16700. private _checkCache;
  16701. /**
  16702. * Specifies that the submesh is ready to be used
  16703. * @param mesh defines the mesh to check
  16704. * @param subMesh defines which submesh to check
  16705. * @param useInstances specifies that instances should be used
  16706. * @returns a boolean indicating that the submesh is ready or not
  16707. */
  16708. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16709. /**
  16710. * Checks if the material is ready to render the requested mesh
  16711. * @param mesh Define the mesh to render
  16712. * @param useInstances Define whether or not the material is used with instances
  16713. * @returns true if ready, otherwise false
  16714. */
  16715. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16716. /**
  16717. * Binds the world matrix to the material
  16718. * @param world defines the world transformation matrix
  16719. * @param effectOverride - If provided, use this effect instead of internal effect
  16720. */
  16721. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16722. /**
  16723. * Binds the submesh to this material by preparing the effect and shader to draw
  16724. * @param world defines the world transformation matrix
  16725. * @param mesh defines the mesh containing the submesh
  16726. * @param subMesh defines the submesh to bind the material to
  16727. */
  16728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16729. /**
  16730. * Binds the material to the mesh
  16731. * @param world defines the world transformation matrix
  16732. * @param mesh defines the mesh to bind the material to
  16733. * @param effectOverride - If provided, use this effect instead of internal effect
  16734. */
  16735. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16736. protected _afterBind(mesh?: Mesh): void;
  16737. /**
  16738. * Gets the active textures from the material
  16739. * @returns an array of textures
  16740. */
  16741. getActiveTextures(): BaseTexture[];
  16742. /**
  16743. * Specifies if the material uses a texture
  16744. * @param texture defines the texture to check against the material
  16745. * @returns a boolean specifying if the material uses the texture
  16746. */
  16747. hasTexture(texture: BaseTexture): boolean;
  16748. /**
  16749. * Makes a duplicate of the material, and gives it a new name
  16750. * @param name defines the new name for the duplicated material
  16751. * @returns the cloned material
  16752. */
  16753. clone(name: string): ShaderMaterial;
  16754. /**
  16755. * Disposes the material
  16756. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16757. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16758. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16759. */
  16760. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16761. /**
  16762. * Serializes this material in a JSON representation
  16763. * @returns the serialized material object
  16764. */
  16765. serialize(): any;
  16766. /**
  16767. * Creates a shader material from parsed shader material data
  16768. * @param source defines the JSON represnetation of the material
  16769. * @param scene defines the hosting scene
  16770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16771. * @returns a new material
  16772. */
  16773. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16774. /**
  16775. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16776. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16777. * @param url defines the url to load from
  16778. * @param scene defines the hosting scene
  16779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16780. * @returns a promise that will resolve to the new ShaderMaterial
  16781. */
  16782. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16783. /**
  16784. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16785. * @param snippetId defines the snippet to load
  16786. * @param scene defines the hosting scene
  16787. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16788. * @returns a promise that will resolve to the new ShaderMaterial
  16789. */
  16790. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16791. }
  16792. }
  16793. declare module BABYLON {
  16794. /** @hidden */
  16795. export var colorPixelShader: {
  16796. name: string;
  16797. shader: string;
  16798. };
  16799. }
  16800. declare module BABYLON {
  16801. /** @hidden */
  16802. export var colorVertexShader: {
  16803. name: string;
  16804. shader: string;
  16805. };
  16806. }
  16807. declare module BABYLON {
  16808. /**
  16809. * Line mesh
  16810. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16811. */
  16812. export class LinesMesh extends Mesh {
  16813. /**
  16814. * If vertex color should be applied to the mesh
  16815. */
  16816. readonly useVertexColor?: boolean | undefined;
  16817. /**
  16818. * If vertex alpha should be applied to the mesh
  16819. */
  16820. readonly useVertexAlpha?: boolean | undefined;
  16821. /**
  16822. * Color of the line (Default: White)
  16823. */
  16824. color: Color3;
  16825. /**
  16826. * Alpha of the line (Default: 1)
  16827. */
  16828. alpha: number;
  16829. /**
  16830. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16831. * This margin is expressed in world space coordinates, so its value may vary.
  16832. * Default value is 0.1
  16833. */
  16834. intersectionThreshold: number;
  16835. private _colorShader;
  16836. private color4;
  16837. /**
  16838. * Creates a new LinesMesh
  16839. * @param name defines the name
  16840. * @param scene defines the hosting scene
  16841. * @param parent defines the parent mesh if any
  16842. * @param source defines the optional source LinesMesh used to clone data from
  16843. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16844. * When false, achieved by calling a clone(), also passing False.
  16845. * This will make creation of children, recursive.
  16846. * @param useVertexColor defines if this LinesMesh supports vertex color
  16847. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16848. */
  16849. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16850. /**
  16851. * If vertex color should be applied to the mesh
  16852. */
  16853. useVertexColor?: boolean | undefined,
  16854. /**
  16855. * If vertex alpha should be applied to the mesh
  16856. */
  16857. useVertexAlpha?: boolean | undefined);
  16858. private _addClipPlaneDefine;
  16859. private _removeClipPlaneDefine;
  16860. isReady(): boolean;
  16861. /**
  16862. * Returns the string "LineMesh"
  16863. */
  16864. getClassName(): string;
  16865. /**
  16866. * @hidden
  16867. */
  16868. get material(): Material;
  16869. /**
  16870. * @hidden
  16871. */
  16872. set material(value: Material);
  16873. /**
  16874. * @hidden
  16875. */
  16876. get checkCollisions(): boolean;
  16877. /** @hidden */
  16878. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16879. /** @hidden */
  16880. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16881. /**
  16882. * Disposes of the line mesh
  16883. * @param doNotRecurse If children should be disposed
  16884. */
  16885. dispose(doNotRecurse?: boolean): void;
  16886. /**
  16887. * Returns a new LineMesh object cloned from the current one.
  16888. */
  16889. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16890. /**
  16891. * Creates a new InstancedLinesMesh object from the mesh model.
  16892. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16893. * @param name defines the name of the new instance
  16894. * @returns a new InstancedLinesMesh
  16895. */
  16896. createInstance(name: string): InstancedLinesMesh;
  16897. }
  16898. /**
  16899. * Creates an instance based on a source LinesMesh
  16900. */
  16901. export class InstancedLinesMesh extends InstancedMesh {
  16902. /**
  16903. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16904. * This margin is expressed in world space coordinates, so its value may vary.
  16905. * Initilized with the intersectionThreshold value of the source LinesMesh
  16906. */
  16907. intersectionThreshold: number;
  16908. constructor(name: string, source: LinesMesh);
  16909. /**
  16910. * Returns the string "InstancedLinesMesh".
  16911. */
  16912. getClassName(): string;
  16913. }
  16914. }
  16915. declare module BABYLON {
  16916. /** @hidden */
  16917. export var linePixelShader: {
  16918. name: string;
  16919. shader: string;
  16920. };
  16921. }
  16922. declare module BABYLON {
  16923. /** @hidden */
  16924. export var lineVertexShader: {
  16925. name: string;
  16926. shader: string;
  16927. };
  16928. }
  16929. declare module BABYLON {
  16930. interface Scene {
  16931. /** @hidden */
  16932. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16933. }
  16934. interface AbstractMesh {
  16935. /**
  16936. * Gets the edgesRenderer associated with the mesh
  16937. */
  16938. edgesRenderer: Nullable<EdgesRenderer>;
  16939. }
  16940. interface LinesMesh {
  16941. /**
  16942. * Enables the edge rendering mode on the mesh.
  16943. * This mode makes the mesh edges visible
  16944. * @param epsilon defines the maximal distance between two angles to detect a face
  16945. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16946. * @returns the currentAbstractMesh
  16947. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16948. */
  16949. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16950. }
  16951. interface InstancedLinesMesh {
  16952. /**
  16953. * Enables the edge rendering mode on the mesh.
  16954. * This mode makes the mesh edges visible
  16955. * @param epsilon defines the maximal distance between two angles to detect a face
  16956. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16957. * @returns the current InstancedLinesMesh
  16958. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16959. */
  16960. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16961. }
  16962. /**
  16963. * Defines the minimum contract an Edges renderer should follow.
  16964. */
  16965. export interface IEdgesRenderer extends IDisposable {
  16966. /**
  16967. * Gets or sets a boolean indicating if the edgesRenderer is active
  16968. */
  16969. isEnabled: boolean;
  16970. /**
  16971. * Renders the edges of the attached mesh,
  16972. */
  16973. render(): void;
  16974. /**
  16975. * Checks wether or not the edges renderer is ready to render.
  16976. * @return true if ready, otherwise false.
  16977. */
  16978. isReady(): boolean;
  16979. /**
  16980. * List of instances to render in case the source mesh has instances
  16981. */
  16982. customInstances: SmartArray<Matrix>;
  16983. }
  16984. /**
  16985. * Defines the additional options of the edges renderer
  16986. */
  16987. export interface IEdgesRendererOptions {
  16988. /**
  16989. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16990. * If not defined, the default value is true
  16991. */
  16992. useAlternateEdgeFinder?: boolean;
  16993. /**
  16994. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16995. * If not defined, the default value is true.
  16996. * 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)
  16997. * This option is used only if useAlternateEdgeFinder = true
  16998. */
  16999. useFastVertexMerger?: boolean;
  17000. /**
  17001. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17002. * The default value is 1e-6
  17003. * This option is used only if useAlternateEdgeFinder = true
  17004. */
  17005. epsilonVertexMerge?: number;
  17006. /**
  17007. * 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
  17008. * 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.
  17009. * This option is used only if useAlternateEdgeFinder = true
  17010. */
  17011. applyTessellation?: boolean;
  17012. /**
  17013. * 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
  17014. * The default value is 1e-6
  17015. * This option is used only if useAlternateEdgeFinder = true
  17016. */
  17017. epsilonVertexAligned?: number;
  17018. }
  17019. /**
  17020. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17021. */
  17022. export class EdgesRenderer implements IEdgesRenderer {
  17023. /**
  17024. * Define the size of the edges with an orthographic camera
  17025. */
  17026. edgesWidthScalerForOrthographic: number;
  17027. /**
  17028. * Define the size of the edges with a perspective camera
  17029. */
  17030. edgesWidthScalerForPerspective: number;
  17031. protected _source: AbstractMesh;
  17032. protected _linesPositions: number[];
  17033. protected _linesNormals: number[];
  17034. protected _linesIndices: number[];
  17035. protected _epsilon: number;
  17036. protected _indicesCount: number;
  17037. protected _lineShader: ShaderMaterial;
  17038. protected _ib: DataBuffer;
  17039. protected _buffers: {
  17040. [key: string]: Nullable<VertexBuffer>;
  17041. };
  17042. protected _buffersForInstances: {
  17043. [key: string]: Nullable<VertexBuffer>;
  17044. };
  17045. protected _checkVerticesInsteadOfIndices: boolean;
  17046. protected _options: Nullable<IEdgesRendererOptions>;
  17047. private _meshRebuildObserver;
  17048. private _meshDisposeObserver;
  17049. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17050. isEnabled: boolean;
  17051. /**
  17052. * List of instances to render in case the source mesh has instances
  17053. */
  17054. customInstances: SmartArray<Matrix>;
  17055. private static GetShader;
  17056. /**
  17057. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17058. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17059. * @param source Mesh used to create edges
  17060. * @param epsilon sum of angles in adjacency to check for edge
  17061. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17062. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17063. * @param options The options to apply when generating the edges
  17064. */
  17065. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17066. protected _prepareRessources(): void;
  17067. /** @hidden */
  17068. _rebuild(): void;
  17069. /**
  17070. * Releases the required resources for the edges renderer
  17071. */
  17072. dispose(): void;
  17073. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17074. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17075. /**
  17076. * Checks if the pair of p0 and p1 is en edge
  17077. * @param faceIndex
  17078. * @param edge
  17079. * @param faceNormals
  17080. * @param p0
  17081. * @param p1
  17082. * @private
  17083. */
  17084. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17085. /**
  17086. * push line into the position, normal and index buffer
  17087. * @protected
  17088. */
  17089. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17090. /**
  17091. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17092. */
  17093. private _tessellateTriangle;
  17094. private _generateEdgesLinesAlternate;
  17095. /**
  17096. * Generates lines edges from adjacencjes
  17097. * @private
  17098. */
  17099. _generateEdgesLines(): void;
  17100. /**
  17101. * Checks wether or not the edges renderer is ready to render.
  17102. * @return true if ready, otherwise false.
  17103. */
  17104. isReady(): boolean;
  17105. /**
  17106. * Renders the edges of the attached mesh,
  17107. */
  17108. render(): void;
  17109. }
  17110. /**
  17111. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17112. */
  17113. export class LineEdgesRenderer extends EdgesRenderer {
  17114. /**
  17115. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17116. * @param source LineMesh used to generate edges
  17117. * @param epsilon not important (specified angle for edge detection)
  17118. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17119. */
  17120. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17121. /**
  17122. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17123. */
  17124. _generateEdgesLines(): void;
  17125. }
  17126. }
  17127. declare module BABYLON {
  17128. /**
  17129. * This represents the object necessary to create a rendering group.
  17130. * This is exclusively used and created by the rendering manager.
  17131. * To modify the behavior, you use the available helpers in your scene or meshes.
  17132. * @hidden
  17133. */
  17134. export class RenderingGroup {
  17135. index: number;
  17136. private static _zeroVector;
  17137. private _scene;
  17138. private _opaqueSubMeshes;
  17139. private _transparentSubMeshes;
  17140. private _alphaTestSubMeshes;
  17141. private _depthOnlySubMeshes;
  17142. private _particleSystems;
  17143. private _spriteManagers;
  17144. private _opaqueSortCompareFn;
  17145. private _alphaTestSortCompareFn;
  17146. private _transparentSortCompareFn;
  17147. private _renderOpaque;
  17148. private _renderAlphaTest;
  17149. private _renderTransparent;
  17150. /** @hidden */
  17151. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17152. onBeforeTransparentRendering: () => void;
  17153. /**
  17154. * Set the opaque sort comparison function.
  17155. * If null the sub meshes will be render in the order they were created
  17156. */
  17157. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17158. /**
  17159. * Set the alpha test sort comparison function.
  17160. * If null the sub meshes will be render in the order they were created
  17161. */
  17162. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17163. /**
  17164. * Set the transparent sort comparison function.
  17165. * If null the sub meshes will be render in the order they were created
  17166. */
  17167. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17168. /**
  17169. * Creates a new rendering group.
  17170. * @param index The rendering group index
  17171. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17172. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17173. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17174. */
  17175. 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>);
  17176. /**
  17177. * Render all the sub meshes contained in the group.
  17178. * @param customRenderFunction Used to override the default render behaviour of the group.
  17179. * @returns true if rendered some submeshes.
  17180. */
  17181. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17182. /**
  17183. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17184. * @param subMeshes The submeshes to render
  17185. */
  17186. private renderOpaqueSorted;
  17187. /**
  17188. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17189. * @param subMeshes The submeshes to render
  17190. */
  17191. private renderAlphaTestSorted;
  17192. /**
  17193. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17194. * @param subMeshes The submeshes to render
  17195. */
  17196. private renderTransparentSorted;
  17197. /**
  17198. * Renders the submeshes in a specified order.
  17199. * @param subMeshes The submeshes to sort before render
  17200. * @param sortCompareFn The comparison function use to sort
  17201. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17202. * @param transparent Specifies to activate blending if true
  17203. */
  17204. private static renderSorted;
  17205. /**
  17206. * Renders the submeshes in the order they were dispatched (no sort applied).
  17207. * @param subMeshes The submeshes to render
  17208. */
  17209. private static renderUnsorted;
  17210. /**
  17211. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17212. * are rendered back to front if in the same alpha index.
  17213. *
  17214. * @param a The first submesh
  17215. * @param b The second submesh
  17216. * @returns The result of the comparison
  17217. */
  17218. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17219. /**
  17220. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17221. * are rendered back to front.
  17222. *
  17223. * @param a The first submesh
  17224. * @param b The second submesh
  17225. * @returns The result of the comparison
  17226. */
  17227. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17228. /**
  17229. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17230. * are rendered front to back (prevent overdraw).
  17231. *
  17232. * @param a The first submesh
  17233. * @param b The second submesh
  17234. * @returns The result of the comparison
  17235. */
  17236. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17237. /**
  17238. * Resets the different lists of submeshes to prepare a new frame.
  17239. */
  17240. prepare(): void;
  17241. dispose(): void;
  17242. /**
  17243. * Inserts the submesh in its correct queue depending on its material.
  17244. * @param subMesh The submesh to dispatch
  17245. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17246. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17247. */
  17248. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17249. dispatchSprites(spriteManager: ISpriteManager): void;
  17250. dispatchParticles(particleSystem: IParticleSystem): void;
  17251. private _renderParticles;
  17252. private _renderSprites;
  17253. }
  17254. }
  17255. declare module BABYLON {
  17256. /**
  17257. * Interface describing the different options available in the rendering manager
  17258. * regarding Auto Clear between groups.
  17259. */
  17260. export interface IRenderingManagerAutoClearSetup {
  17261. /**
  17262. * Defines whether or not autoclear is enable.
  17263. */
  17264. autoClear: boolean;
  17265. /**
  17266. * Defines whether or not to autoclear the depth buffer.
  17267. */
  17268. depth: boolean;
  17269. /**
  17270. * Defines whether or not to autoclear the stencil buffer.
  17271. */
  17272. stencil: boolean;
  17273. }
  17274. /**
  17275. * This class is used by the onRenderingGroupObservable
  17276. */
  17277. export class RenderingGroupInfo {
  17278. /**
  17279. * The Scene that being rendered
  17280. */
  17281. scene: Scene;
  17282. /**
  17283. * The camera currently used for the rendering pass
  17284. */
  17285. camera: Nullable<Camera>;
  17286. /**
  17287. * The ID of the renderingGroup being processed
  17288. */
  17289. renderingGroupId: number;
  17290. }
  17291. /**
  17292. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17293. * It is enable to manage the different groups as well as the different necessary sort functions.
  17294. * This should not be used directly aside of the few static configurations
  17295. */
  17296. export class RenderingManager {
  17297. /**
  17298. * The max id used for rendering groups (not included)
  17299. */
  17300. static MAX_RENDERINGGROUPS: number;
  17301. /**
  17302. * The min id used for rendering groups (included)
  17303. */
  17304. static MIN_RENDERINGGROUPS: number;
  17305. /**
  17306. * Used to globally prevent autoclearing scenes.
  17307. */
  17308. static AUTOCLEAR: boolean;
  17309. /**
  17310. * @hidden
  17311. */
  17312. _useSceneAutoClearSetup: boolean;
  17313. private _scene;
  17314. private _renderingGroups;
  17315. private _depthStencilBufferAlreadyCleaned;
  17316. private _autoClearDepthStencil;
  17317. private _customOpaqueSortCompareFn;
  17318. private _customAlphaTestSortCompareFn;
  17319. private _customTransparentSortCompareFn;
  17320. private _renderingGroupInfo;
  17321. /**
  17322. * Instantiates a new rendering group for a particular scene
  17323. * @param scene Defines the scene the groups belongs to
  17324. */
  17325. constructor(scene: Scene);
  17326. private _clearDepthStencilBuffer;
  17327. /**
  17328. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17329. * @hidden
  17330. */
  17331. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17332. /**
  17333. * Resets the different information of the group to prepare a new frame
  17334. * @hidden
  17335. */
  17336. reset(): void;
  17337. /**
  17338. * Dispose and release the group and its associated resources.
  17339. * @hidden
  17340. */
  17341. dispose(): void;
  17342. /**
  17343. * Clear the info related to rendering groups preventing retention points during dispose.
  17344. */
  17345. freeRenderingGroups(): void;
  17346. private _prepareRenderingGroup;
  17347. /**
  17348. * Add a sprite manager to the rendering manager in order to render it this frame.
  17349. * @param spriteManager Define the sprite manager to render
  17350. */
  17351. dispatchSprites(spriteManager: ISpriteManager): void;
  17352. /**
  17353. * Add a particle system to the rendering manager in order to render it this frame.
  17354. * @param particleSystem Define the particle system to render
  17355. */
  17356. dispatchParticles(particleSystem: IParticleSystem): void;
  17357. /**
  17358. * Add a submesh to the manager in order to render it this frame
  17359. * @param subMesh The submesh to dispatch
  17360. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17361. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17362. */
  17363. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17364. /**
  17365. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17366. * This allowed control for front to back rendering or reversly depending of the special needs.
  17367. *
  17368. * @param renderingGroupId The rendering group id corresponding to its index
  17369. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17370. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17371. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17372. */
  17373. 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;
  17374. /**
  17375. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17376. *
  17377. * @param renderingGroupId The rendering group id corresponding to its index
  17378. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17379. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17380. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17381. */
  17382. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17383. /**
  17384. * Gets the current auto clear configuration for one rendering group of the rendering
  17385. * manager.
  17386. * @param index the rendering group index to get the information for
  17387. * @returns The auto clear setup for the requested rendering group
  17388. */
  17389. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17390. }
  17391. }
  17392. declare module BABYLON {
  17393. /**
  17394. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17395. */
  17396. export interface ICustomShaderOptions {
  17397. /**
  17398. * Gets or sets the custom shader name to use
  17399. */
  17400. shaderName: string;
  17401. /**
  17402. * The list of attribute names used in the shader
  17403. */
  17404. attributes?: string[];
  17405. /**
  17406. * The list of unifrom names used in the shader
  17407. */
  17408. uniforms?: string[];
  17409. /**
  17410. * The list of sampler names used in the shader
  17411. */
  17412. samplers?: string[];
  17413. /**
  17414. * The list of defines used in the shader
  17415. */
  17416. defines?: string[];
  17417. }
  17418. /**
  17419. * Interface to implement to create a shadow generator compatible with BJS.
  17420. */
  17421. export interface IShadowGenerator {
  17422. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17423. id: string;
  17424. /**
  17425. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17426. * @returns The render target texture if present otherwise, null
  17427. */
  17428. getShadowMap(): Nullable<RenderTargetTexture>;
  17429. /**
  17430. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17431. * @param subMesh The submesh we want to render in the shadow map
  17432. * @param useInstances Defines wether will draw in the map using instances
  17433. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17434. * @returns true if ready otherwise, false
  17435. */
  17436. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17437. /**
  17438. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17439. * @param defines Defines of the material we want to update
  17440. * @param lightIndex Index of the light in the enabled light list of the material
  17441. */
  17442. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17443. /**
  17444. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17445. * defined in the generator but impacting the effect).
  17446. * It implies the unifroms available on the materials are the standard BJS ones.
  17447. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17448. * @param effect The effect we are binfing the information for
  17449. */
  17450. bindShadowLight(lightIndex: string, effect: Effect): void;
  17451. /**
  17452. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17453. * (eq to shadow prjection matrix * light transform matrix)
  17454. * @returns The transform matrix used to create the shadow map
  17455. */
  17456. getTransformMatrix(): Matrix;
  17457. /**
  17458. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17459. * Cube and 2D textures for instance.
  17460. */
  17461. recreateShadowMap(): void;
  17462. /**
  17463. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17464. * @param onCompiled Callback triggered at the and of the effects compilation
  17465. * @param options Sets of optional options forcing the compilation with different modes
  17466. */
  17467. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17468. useInstances: boolean;
  17469. }>): void;
  17470. /**
  17471. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17472. * @param options Sets of optional options forcing the compilation with different modes
  17473. * @returns A promise that resolves when the compilation completes
  17474. */
  17475. forceCompilationAsync(options?: Partial<{
  17476. useInstances: boolean;
  17477. }>): Promise<void>;
  17478. /**
  17479. * Serializes the shadow generator setup to a json object.
  17480. * @returns The serialized JSON object
  17481. */
  17482. serialize(): any;
  17483. /**
  17484. * Disposes the Shadow map and related Textures and effects.
  17485. */
  17486. dispose(): void;
  17487. }
  17488. /**
  17489. * Default implementation IShadowGenerator.
  17490. * This is the main object responsible of generating shadows in the framework.
  17491. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17492. */
  17493. export class ShadowGenerator implements IShadowGenerator {
  17494. /**
  17495. * Name of the shadow generator class
  17496. */
  17497. static CLASSNAME: string;
  17498. /**
  17499. * Shadow generator mode None: no filtering applied.
  17500. */
  17501. static readonly FILTER_NONE: number;
  17502. /**
  17503. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17504. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17505. */
  17506. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17507. /**
  17508. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17509. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17510. */
  17511. static readonly FILTER_POISSONSAMPLING: number;
  17512. /**
  17513. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17514. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17515. */
  17516. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17517. /**
  17518. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17519. * edge artifacts on steep falloff.
  17520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17521. */
  17522. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17523. /**
  17524. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17525. * edge artifacts on steep falloff.
  17526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17527. */
  17528. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17529. /**
  17530. * Shadow generator mode PCF: Percentage Closer Filtering
  17531. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17532. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17533. */
  17534. static readonly FILTER_PCF: number;
  17535. /**
  17536. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17538. * Contact Hardening
  17539. */
  17540. static readonly FILTER_PCSS: number;
  17541. /**
  17542. * Reserved for PCF and PCSS
  17543. * Highest Quality.
  17544. *
  17545. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17546. *
  17547. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17548. */
  17549. static readonly QUALITY_HIGH: number;
  17550. /**
  17551. * Reserved for PCF and PCSS
  17552. * Good tradeoff for quality/perf cross devices
  17553. *
  17554. * Execute PCF on a 3*3 kernel.
  17555. *
  17556. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17557. */
  17558. static readonly QUALITY_MEDIUM: number;
  17559. /**
  17560. * Reserved for PCF and PCSS
  17561. * The lowest quality but the fastest.
  17562. *
  17563. * Execute PCF on a 1*1 kernel.
  17564. *
  17565. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17566. */
  17567. static readonly QUALITY_LOW: number;
  17568. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17569. id: string;
  17570. /** Gets or sets the custom shader name to use */
  17571. customShaderOptions: ICustomShaderOptions;
  17572. /**
  17573. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17574. */
  17575. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17576. /**
  17577. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17578. */
  17579. onAfterShadowMapRenderObservable: Observable<Effect>;
  17580. /**
  17581. * Observable triggered before a mesh is rendered in the shadow map.
  17582. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17583. */
  17584. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17585. /**
  17586. * Observable triggered after a mesh is rendered in the shadow map.
  17587. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17588. */
  17589. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17590. protected _bias: number;
  17591. /**
  17592. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17593. */
  17594. get bias(): number;
  17595. /**
  17596. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17597. */
  17598. set bias(bias: number);
  17599. protected _normalBias: number;
  17600. /**
  17601. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17602. */
  17603. get normalBias(): number;
  17604. /**
  17605. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17606. */
  17607. set normalBias(normalBias: number);
  17608. protected _blurBoxOffset: number;
  17609. /**
  17610. * Gets the blur box offset: offset applied during the blur pass.
  17611. * Only useful if useKernelBlur = false
  17612. */
  17613. get blurBoxOffset(): number;
  17614. /**
  17615. * Sets the blur box offset: offset applied during the blur pass.
  17616. * Only useful if useKernelBlur = false
  17617. */
  17618. set blurBoxOffset(value: number);
  17619. protected _blurScale: number;
  17620. /**
  17621. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17622. * 2 means half of the size.
  17623. */
  17624. get blurScale(): number;
  17625. /**
  17626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17627. * 2 means half of the size.
  17628. */
  17629. set blurScale(value: number);
  17630. protected _blurKernel: number;
  17631. /**
  17632. * Gets the blur kernel: kernel size of the blur pass.
  17633. * Only useful if useKernelBlur = true
  17634. */
  17635. get blurKernel(): number;
  17636. /**
  17637. * Sets the blur kernel: kernel size of the blur pass.
  17638. * Only useful if useKernelBlur = true
  17639. */
  17640. set blurKernel(value: number);
  17641. protected _useKernelBlur: boolean;
  17642. /**
  17643. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17644. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17645. */
  17646. get useKernelBlur(): boolean;
  17647. /**
  17648. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17649. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17650. */
  17651. set useKernelBlur(value: boolean);
  17652. protected _depthScale: number;
  17653. /**
  17654. * Gets the depth scale used in ESM mode.
  17655. */
  17656. get depthScale(): number;
  17657. /**
  17658. * Sets the depth scale used in ESM mode.
  17659. * This can override the scale stored on the light.
  17660. */
  17661. set depthScale(value: number);
  17662. protected _validateFilter(filter: number): number;
  17663. protected _filter: number;
  17664. /**
  17665. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17667. */
  17668. get filter(): number;
  17669. /**
  17670. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17671. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17672. */
  17673. set filter(value: number);
  17674. /**
  17675. * Gets if the current filter is set to Poisson Sampling.
  17676. */
  17677. get usePoissonSampling(): boolean;
  17678. /**
  17679. * Sets the current filter to Poisson Sampling.
  17680. */
  17681. set usePoissonSampling(value: boolean);
  17682. /**
  17683. * Gets if the current filter is set to ESM.
  17684. */
  17685. get useExponentialShadowMap(): boolean;
  17686. /**
  17687. * Sets the current filter is to ESM.
  17688. */
  17689. set useExponentialShadowMap(value: boolean);
  17690. /**
  17691. * Gets if the current filter is set to filtered ESM.
  17692. */
  17693. get useBlurExponentialShadowMap(): boolean;
  17694. /**
  17695. * Gets if the current filter is set to filtered ESM.
  17696. */
  17697. set useBlurExponentialShadowMap(value: boolean);
  17698. /**
  17699. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17700. * exponential to prevent steep falloff artifacts).
  17701. */
  17702. get useCloseExponentialShadowMap(): boolean;
  17703. /**
  17704. * Sets the current filter to "close ESM" (using the inverse of the
  17705. * exponential to prevent steep falloff artifacts).
  17706. */
  17707. set useCloseExponentialShadowMap(value: boolean);
  17708. /**
  17709. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17710. * exponential to prevent steep falloff artifacts).
  17711. */
  17712. get useBlurCloseExponentialShadowMap(): boolean;
  17713. /**
  17714. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17715. * exponential to prevent steep falloff artifacts).
  17716. */
  17717. set useBlurCloseExponentialShadowMap(value: boolean);
  17718. /**
  17719. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17720. */
  17721. get usePercentageCloserFiltering(): boolean;
  17722. /**
  17723. * Sets the current filter to "PCF" (percentage closer filtering).
  17724. */
  17725. set usePercentageCloserFiltering(value: boolean);
  17726. protected _filteringQuality: number;
  17727. /**
  17728. * Gets the PCF or PCSS Quality.
  17729. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17730. */
  17731. get filteringQuality(): number;
  17732. /**
  17733. * Sets the PCF or PCSS Quality.
  17734. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17735. */
  17736. set filteringQuality(filteringQuality: number);
  17737. /**
  17738. * Gets if the current filter is set to "PCSS" (contact hardening).
  17739. */
  17740. get useContactHardeningShadow(): boolean;
  17741. /**
  17742. * Sets the current filter to "PCSS" (contact hardening).
  17743. */
  17744. set useContactHardeningShadow(value: boolean);
  17745. protected _contactHardeningLightSizeUVRatio: number;
  17746. /**
  17747. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17748. * Using a ratio helps keeping shape stability independently of the map size.
  17749. *
  17750. * It does not account for the light projection as it was having too much
  17751. * instability during the light setup or during light position changes.
  17752. *
  17753. * Only valid if useContactHardeningShadow is true.
  17754. */
  17755. get contactHardeningLightSizeUVRatio(): number;
  17756. /**
  17757. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17758. * Using a ratio helps keeping shape stability independently of the map size.
  17759. *
  17760. * It does not account for the light projection as it was having too much
  17761. * instability during the light setup or during light position changes.
  17762. *
  17763. * Only valid if useContactHardeningShadow is true.
  17764. */
  17765. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17766. protected _darkness: number;
  17767. /** Gets or sets the actual darkness of a shadow */
  17768. get darkness(): number;
  17769. set darkness(value: number);
  17770. /**
  17771. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17772. * 0 means strongest and 1 would means no shadow.
  17773. * @returns the darkness.
  17774. */
  17775. getDarkness(): number;
  17776. /**
  17777. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17778. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17779. * @returns the shadow generator allowing fluent coding.
  17780. */
  17781. setDarkness(darkness: number): ShadowGenerator;
  17782. protected _transparencyShadow: boolean;
  17783. /** Gets or sets the ability to have transparent shadow */
  17784. get transparencyShadow(): boolean;
  17785. set transparencyShadow(value: boolean);
  17786. /**
  17787. * Sets the ability to have transparent shadow (boolean).
  17788. * @param transparent True if transparent else False
  17789. * @returns the shadow generator allowing fluent coding
  17790. */
  17791. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17792. /**
  17793. * Enables or disables shadows with varying strength based on the transparency
  17794. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17795. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17796. * mesh.visibility * alphaTexture.a
  17797. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17798. */
  17799. enableSoftTransparentShadow: boolean;
  17800. protected _shadowMap: Nullable<RenderTargetTexture>;
  17801. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17802. /**
  17803. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17804. * @returns The render target texture if present otherwise, null
  17805. */
  17806. getShadowMap(): Nullable<RenderTargetTexture>;
  17807. /**
  17808. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17809. * @returns The render target texture if the shadow map is present otherwise, null
  17810. */
  17811. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17812. /**
  17813. * Gets the class name of that object
  17814. * @returns "ShadowGenerator"
  17815. */
  17816. getClassName(): string;
  17817. /**
  17818. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17819. * @param mesh Mesh to add
  17820. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17821. * @returns the Shadow Generator itself
  17822. */
  17823. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17824. /**
  17825. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17826. * @param mesh Mesh to remove
  17827. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17828. * @returns the Shadow Generator itself
  17829. */
  17830. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17831. /**
  17832. * Controls the extent to which the shadows fade out at the edge of the frustum
  17833. */
  17834. frustumEdgeFalloff: number;
  17835. protected _light: IShadowLight;
  17836. /**
  17837. * Returns the associated light object.
  17838. * @returns the light generating the shadow
  17839. */
  17840. getLight(): IShadowLight;
  17841. /**
  17842. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17843. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17844. * It might on the other hand introduce peter panning.
  17845. */
  17846. forceBackFacesOnly: boolean;
  17847. protected _scene: Scene;
  17848. protected _lightDirection: Vector3;
  17849. protected _effect: Effect;
  17850. protected _viewMatrix: Matrix;
  17851. protected _projectionMatrix: Matrix;
  17852. protected _transformMatrix: Matrix;
  17853. protected _cachedPosition: Vector3;
  17854. protected _cachedDirection: Vector3;
  17855. protected _cachedDefines: string;
  17856. protected _currentRenderID: number;
  17857. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17858. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17859. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17860. protected _blurPostProcesses: PostProcess[];
  17861. protected _mapSize: number;
  17862. protected _currentFaceIndex: number;
  17863. protected _currentFaceIndexCache: number;
  17864. protected _textureType: number;
  17865. protected _defaultTextureMatrix: Matrix;
  17866. protected _storedUniqueId: Nullable<number>;
  17867. /** @hidden */
  17868. static _SceneComponentInitialization: (scene: Scene) => void;
  17869. /**
  17870. * Creates a ShadowGenerator object.
  17871. * A ShadowGenerator is the required tool to use the shadows.
  17872. * Each light casting shadows needs to use its own ShadowGenerator.
  17873. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17874. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17875. * @param light The light object generating the shadows.
  17876. * @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.
  17877. */
  17878. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17879. protected _initializeGenerator(): void;
  17880. protected _createTargetRenderTexture(): void;
  17881. protected _initializeShadowMap(): void;
  17882. protected _initializeBlurRTTAndPostProcesses(): void;
  17883. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17884. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17885. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17886. protected _applyFilterValues(): void;
  17887. /**
  17888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17889. * @param onCompiled Callback triggered at the and of the effects compilation
  17890. * @param options Sets of optional options forcing the compilation with different modes
  17891. */
  17892. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17893. useInstances: boolean;
  17894. }>): void;
  17895. /**
  17896. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17897. * @param options Sets of optional options forcing the compilation with different modes
  17898. * @returns A promise that resolves when the compilation completes
  17899. */
  17900. forceCompilationAsync(options?: Partial<{
  17901. useInstances: boolean;
  17902. }>): Promise<void>;
  17903. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17904. private _prepareShadowDefines;
  17905. /**
  17906. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17907. * @param subMesh The submesh we want to render in the shadow map
  17908. * @param useInstances Defines wether will draw in the map using instances
  17909. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17910. * @returns true if ready otherwise, false
  17911. */
  17912. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17913. /**
  17914. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17915. * @param defines Defines of the material we want to update
  17916. * @param lightIndex Index of the light in the enabled light list of the material
  17917. */
  17918. prepareDefines(defines: any, lightIndex: number): void;
  17919. /**
  17920. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17921. * defined in the generator but impacting the effect).
  17922. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17923. * @param effect The effect we are binfing the information for
  17924. */
  17925. bindShadowLight(lightIndex: string, effect: Effect): void;
  17926. /**
  17927. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17928. * (eq to shadow prjection matrix * light transform matrix)
  17929. * @returns The transform matrix used to create the shadow map
  17930. */
  17931. getTransformMatrix(): Matrix;
  17932. /**
  17933. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17934. * Cube and 2D textures for instance.
  17935. */
  17936. recreateShadowMap(): void;
  17937. protected _disposeBlurPostProcesses(): void;
  17938. protected _disposeRTTandPostProcesses(): void;
  17939. /**
  17940. * Disposes the ShadowGenerator.
  17941. * Returns nothing.
  17942. */
  17943. dispose(): void;
  17944. /**
  17945. * Serializes the shadow generator setup to a json object.
  17946. * @returns The serialized JSON object
  17947. */
  17948. serialize(): any;
  17949. /**
  17950. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17951. * @param parsedShadowGenerator The JSON object to parse
  17952. * @param scene The scene to create the shadow map for
  17953. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17954. * @returns The parsed shadow generator
  17955. */
  17956. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17957. }
  17958. }
  17959. declare module BABYLON {
  17960. /**
  17961. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17962. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17963. * 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.
  17964. */
  17965. export abstract class Light extends Node {
  17966. /**
  17967. * Falloff Default: light is falling off following the material specification:
  17968. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17969. */
  17970. static readonly FALLOFF_DEFAULT: number;
  17971. /**
  17972. * Falloff Physical: light is falling off following the inverse squared distance law.
  17973. */
  17974. static readonly FALLOFF_PHYSICAL: number;
  17975. /**
  17976. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17977. * to enhance interoperability with other engines.
  17978. */
  17979. static readonly FALLOFF_GLTF: number;
  17980. /**
  17981. * Falloff Standard: light is falling off like in the standard material
  17982. * to enhance interoperability with other materials.
  17983. */
  17984. static readonly FALLOFF_STANDARD: number;
  17985. /**
  17986. * If every light affecting the material is in this lightmapMode,
  17987. * material.lightmapTexture adds or multiplies
  17988. * (depends on material.useLightmapAsShadowmap)
  17989. * after every other light calculations.
  17990. */
  17991. static readonly LIGHTMAP_DEFAULT: number;
  17992. /**
  17993. * material.lightmapTexture as only diffuse lighting from this light
  17994. * adds only specular lighting from this light
  17995. * adds dynamic shadows
  17996. */
  17997. static readonly LIGHTMAP_SPECULAR: number;
  17998. /**
  17999. * material.lightmapTexture as only lighting
  18000. * no light calculation from this light
  18001. * only adds dynamic shadows from this light
  18002. */
  18003. static readonly LIGHTMAP_SHADOWSONLY: number;
  18004. /**
  18005. * Each light type uses the default quantity according to its type:
  18006. * point/spot lights use luminous intensity
  18007. * directional lights use illuminance
  18008. */
  18009. static readonly INTENSITYMODE_AUTOMATIC: number;
  18010. /**
  18011. * lumen (lm)
  18012. */
  18013. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18014. /**
  18015. * candela (lm/sr)
  18016. */
  18017. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18018. /**
  18019. * lux (lm/m^2)
  18020. */
  18021. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18022. /**
  18023. * nit (cd/m^2)
  18024. */
  18025. static readonly INTENSITYMODE_LUMINANCE: number;
  18026. /**
  18027. * Light type const id of the point light.
  18028. */
  18029. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18030. /**
  18031. * Light type const id of the directional light.
  18032. */
  18033. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18034. /**
  18035. * Light type const id of the spot light.
  18036. */
  18037. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18038. /**
  18039. * Light type const id of the hemispheric light.
  18040. */
  18041. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18042. /**
  18043. * Diffuse gives the basic color to an object.
  18044. */
  18045. diffuse: Color3;
  18046. /**
  18047. * Specular produces a highlight color on an object.
  18048. * Note: This is note affecting PBR materials.
  18049. */
  18050. specular: Color3;
  18051. /**
  18052. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18053. * falling off base on range or angle.
  18054. * This can be set to any values in Light.FALLOFF_x.
  18055. *
  18056. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18057. * other types of materials.
  18058. */
  18059. falloffType: number;
  18060. /**
  18061. * Strength of the light.
  18062. * Note: By default it is define in the framework own unit.
  18063. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18064. */
  18065. intensity: number;
  18066. private _range;
  18067. protected _inverseSquaredRange: number;
  18068. /**
  18069. * Defines how far from the source the light is impacting in scene units.
  18070. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18071. */
  18072. get range(): number;
  18073. /**
  18074. * Defines how far from the source the light is impacting in scene units.
  18075. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18076. */
  18077. set range(value: number);
  18078. /**
  18079. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18080. * of light.
  18081. */
  18082. private _photometricScale;
  18083. private _intensityMode;
  18084. /**
  18085. * Gets the photometric scale used to interpret the intensity.
  18086. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18087. */
  18088. get intensityMode(): number;
  18089. /**
  18090. * Sets the photometric scale used to interpret the intensity.
  18091. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18092. */
  18093. set intensityMode(value: number);
  18094. private _radius;
  18095. /**
  18096. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18097. */
  18098. get radius(): number;
  18099. /**
  18100. * sets the light radius used by PBR Materials to simulate soft area lights.
  18101. */
  18102. set radius(value: number);
  18103. private _renderPriority;
  18104. /**
  18105. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18106. * exceeding the number allowed of the materials.
  18107. */
  18108. renderPriority: number;
  18109. private _shadowEnabled;
  18110. /**
  18111. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18112. * the current shadow generator.
  18113. */
  18114. get shadowEnabled(): boolean;
  18115. /**
  18116. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18117. * the current shadow generator.
  18118. */
  18119. set shadowEnabled(value: boolean);
  18120. private _includedOnlyMeshes;
  18121. /**
  18122. * Gets the only meshes impacted by this light.
  18123. */
  18124. get includedOnlyMeshes(): AbstractMesh[];
  18125. /**
  18126. * Sets the only meshes impacted by this light.
  18127. */
  18128. set includedOnlyMeshes(value: AbstractMesh[]);
  18129. private _excludedMeshes;
  18130. /**
  18131. * Gets the meshes not impacted by this light.
  18132. */
  18133. get excludedMeshes(): AbstractMesh[];
  18134. /**
  18135. * Sets the meshes not impacted by this light.
  18136. */
  18137. set excludedMeshes(value: AbstractMesh[]);
  18138. private _excludeWithLayerMask;
  18139. /**
  18140. * Gets the layer id use to find what meshes are not impacted by the light.
  18141. * Inactive if 0
  18142. */
  18143. get excludeWithLayerMask(): number;
  18144. /**
  18145. * Sets the layer id use to find what meshes are not impacted by the light.
  18146. * Inactive if 0
  18147. */
  18148. set excludeWithLayerMask(value: number);
  18149. private _includeOnlyWithLayerMask;
  18150. /**
  18151. * Gets the layer id use to find what meshes are impacted by the light.
  18152. * Inactive if 0
  18153. */
  18154. get includeOnlyWithLayerMask(): number;
  18155. /**
  18156. * Sets the layer id use to find what meshes are impacted by the light.
  18157. * Inactive if 0
  18158. */
  18159. set includeOnlyWithLayerMask(value: number);
  18160. private _lightmapMode;
  18161. /**
  18162. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18163. */
  18164. get lightmapMode(): number;
  18165. /**
  18166. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18167. */
  18168. set lightmapMode(value: number);
  18169. /**
  18170. * Shadow generator associted to the light.
  18171. * @hidden Internal use only.
  18172. */
  18173. _shadowGenerator: Nullable<IShadowGenerator>;
  18174. /**
  18175. * @hidden Internal use only.
  18176. */
  18177. _excludedMeshesIds: string[];
  18178. /**
  18179. * @hidden Internal use only.
  18180. */
  18181. _includedOnlyMeshesIds: string[];
  18182. /**
  18183. * The current light unifom buffer.
  18184. * @hidden Internal use only.
  18185. */
  18186. _uniformBuffer: UniformBuffer;
  18187. /** @hidden */
  18188. _renderId: number;
  18189. /**
  18190. * Creates a Light object in the scene.
  18191. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18192. * @param name The firendly name of the light
  18193. * @param scene The scene the light belongs too
  18194. */
  18195. constructor(name: string, scene: Scene);
  18196. protected abstract _buildUniformLayout(): void;
  18197. /**
  18198. * Sets the passed Effect "effect" with the Light information.
  18199. * @param effect The effect to update
  18200. * @param lightIndex The index of the light in the effect to update
  18201. * @returns The light
  18202. */
  18203. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18204. /**
  18205. * Sets the passed Effect "effect" with the Light textures.
  18206. * @param effect The effect to update
  18207. * @param lightIndex The index of the light in the effect to update
  18208. * @returns The light
  18209. */
  18210. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18211. /**
  18212. * Binds the lights information from the scene to the effect for the given mesh.
  18213. * @param lightIndex Light index
  18214. * @param scene The scene where the light belongs to
  18215. * @param effect The effect we are binding the data to
  18216. * @param useSpecular Defines if specular is supported
  18217. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18218. */
  18219. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18220. /**
  18221. * Sets the passed Effect "effect" with the Light information.
  18222. * @param effect The effect to update
  18223. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18224. * @returns The light
  18225. */
  18226. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18227. /**
  18228. * Returns the string "Light".
  18229. * @returns the class name
  18230. */
  18231. getClassName(): string;
  18232. /** @hidden */
  18233. readonly _isLight: boolean;
  18234. /**
  18235. * Converts the light information to a readable string for debug purpose.
  18236. * @param fullDetails Supports for multiple levels of logging within scene loading
  18237. * @returns the human readable light info
  18238. */
  18239. toString(fullDetails?: boolean): string;
  18240. /** @hidden */
  18241. protected _syncParentEnabledState(): void;
  18242. /**
  18243. * Set the enabled state of this node.
  18244. * @param value - the new enabled state
  18245. */
  18246. setEnabled(value: boolean): void;
  18247. /**
  18248. * Returns the Light associated shadow generator if any.
  18249. * @return the associated shadow generator.
  18250. */
  18251. getShadowGenerator(): Nullable<IShadowGenerator>;
  18252. /**
  18253. * Returns a Vector3, the absolute light position in the World.
  18254. * @returns the world space position of the light
  18255. */
  18256. getAbsolutePosition(): Vector3;
  18257. /**
  18258. * Specifies if the light will affect the passed mesh.
  18259. * @param mesh The mesh to test against the light
  18260. * @return true the mesh is affected otherwise, false.
  18261. */
  18262. canAffectMesh(mesh: AbstractMesh): boolean;
  18263. /**
  18264. * Sort function to order lights for rendering.
  18265. * @param a First Light object to compare to second.
  18266. * @param b Second Light object to compare first.
  18267. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18268. */
  18269. static CompareLightsPriority(a: Light, b: Light): number;
  18270. /**
  18271. * Releases resources associated with this node.
  18272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18274. */
  18275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18276. /**
  18277. * Returns the light type ID (integer).
  18278. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18279. */
  18280. getTypeID(): number;
  18281. /**
  18282. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18283. * @returns the scaled intensity in intensity mode unit
  18284. */
  18285. getScaledIntensity(): number;
  18286. /**
  18287. * Returns a new Light object, named "name", from the current one.
  18288. * @param name The name of the cloned light
  18289. * @param newParent The parent of this light, if it has one
  18290. * @returns the new created light
  18291. */
  18292. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18293. /**
  18294. * Serializes the current light into a Serialization object.
  18295. * @returns the serialized object.
  18296. */
  18297. serialize(): any;
  18298. /**
  18299. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18300. * This new light is named "name" and added to the passed scene.
  18301. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18302. * @param name The friendly name of the light
  18303. * @param scene The scene the new light will belong to
  18304. * @returns the constructor function
  18305. */
  18306. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18307. /**
  18308. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18309. * @param parsedLight The JSON representation of the light
  18310. * @param scene The scene to create the parsed light in
  18311. * @returns the created light after parsing
  18312. */
  18313. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18314. private _hookArrayForExcluded;
  18315. private _hookArrayForIncludedOnly;
  18316. private _resyncMeshes;
  18317. /**
  18318. * Forces the meshes to update their light related information in their rendering used effects
  18319. * @hidden Internal Use Only
  18320. */
  18321. _markMeshesAsLightDirty(): void;
  18322. /**
  18323. * Recomputes the cached photometric scale if needed.
  18324. */
  18325. private _computePhotometricScale;
  18326. /**
  18327. * Returns the Photometric Scale according to the light type and intensity mode.
  18328. */
  18329. private _getPhotometricScale;
  18330. /**
  18331. * Reorder the light in the scene according to their defined priority.
  18332. * @hidden Internal Use Only
  18333. */
  18334. _reorderLightsInScene(): void;
  18335. /**
  18336. * Prepares the list of defines specific to the light type.
  18337. * @param defines the list of defines
  18338. * @param lightIndex defines the index of the light for the effect
  18339. */
  18340. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18341. }
  18342. }
  18343. declare module BABYLON {
  18344. /**
  18345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18346. * This is the base of the follow, arc rotate cameras and Free camera
  18347. * @see https://doc.babylonjs.com/features/cameras
  18348. */
  18349. export class TargetCamera extends Camera {
  18350. private static _RigCamTransformMatrix;
  18351. private static _TargetTransformMatrix;
  18352. private static _TargetFocalPoint;
  18353. private _tmpUpVector;
  18354. private _tmpTargetVector;
  18355. /**
  18356. * Define the current direction the camera is moving to
  18357. */
  18358. cameraDirection: Vector3;
  18359. /**
  18360. * Define the current rotation the camera is rotating to
  18361. */
  18362. cameraRotation: Vector2;
  18363. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18364. ignoreParentScaling: boolean;
  18365. /**
  18366. * When set, the up vector of the camera will be updated by the rotation of the camera
  18367. */
  18368. updateUpVectorFromRotation: boolean;
  18369. private _tmpQuaternion;
  18370. /**
  18371. * Define the current rotation of the camera
  18372. */
  18373. rotation: Vector3;
  18374. /**
  18375. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18376. */
  18377. rotationQuaternion: Quaternion;
  18378. /**
  18379. * Define the current speed of the camera
  18380. */
  18381. speed: number;
  18382. /**
  18383. * Add constraint to the camera to prevent it to move freely in all directions and
  18384. * around all axis.
  18385. */
  18386. noRotationConstraint: boolean;
  18387. /**
  18388. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18389. * panning
  18390. */
  18391. invertRotation: boolean;
  18392. /**
  18393. * Speed multiplier for inverse camera panning
  18394. */
  18395. inverseRotationSpeed: number;
  18396. /**
  18397. * Define the current target of the camera as an object or a position.
  18398. */
  18399. lockedTarget: any;
  18400. /** @hidden */
  18401. _currentTarget: Vector3;
  18402. /** @hidden */
  18403. _initialFocalDistance: number;
  18404. /** @hidden */
  18405. _viewMatrix: Matrix;
  18406. /** @hidden */
  18407. _camMatrix: Matrix;
  18408. /** @hidden */
  18409. _cameraTransformMatrix: Matrix;
  18410. /** @hidden */
  18411. _cameraRotationMatrix: Matrix;
  18412. /** @hidden */
  18413. _referencePoint: Vector3;
  18414. /** @hidden */
  18415. _transformedReferencePoint: Vector3;
  18416. /** @hidden */
  18417. _reset: () => void;
  18418. private _defaultUp;
  18419. /**
  18420. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18421. * This is the base of the follow, arc rotate cameras and Free camera
  18422. * @see https://doc.babylonjs.com/features/cameras
  18423. * @param name Defines the name of the camera in the scene
  18424. * @param position Defines the start position of the camera in the scene
  18425. * @param scene Defines the scene the camera belongs to
  18426. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18427. */
  18428. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18429. /**
  18430. * Gets the position in front of the camera at a given distance.
  18431. * @param distance The distance from the camera we want the position to be
  18432. * @returns the position
  18433. */
  18434. getFrontPosition(distance: number): Vector3;
  18435. /** @hidden */
  18436. _getLockedTargetPosition(): Nullable<Vector3>;
  18437. private _storedPosition;
  18438. private _storedRotation;
  18439. private _storedRotationQuaternion;
  18440. /**
  18441. * Store current camera state of the camera (fov, position, rotation, etc..)
  18442. * @returns the camera
  18443. */
  18444. storeState(): Camera;
  18445. /**
  18446. * Restored camera state. You must call storeState() first
  18447. * @returns whether it was successful or not
  18448. * @hidden
  18449. */
  18450. _restoreStateValues(): boolean;
  18451. /** @hidden */
  18452. _initCache(): void;
  18453. /** @hidden */
  18454. _updateCache(ignoreParentClass?: boolean): void;
  18455. /** @hidden */
  18456. _isSynchronizedViewMatrix(): boolean;
  18457. /** @hidden */
  18458. _computeLocalCameraSpeed(): number;
  18459. /**
  18460. * Defines the target the camera should look at.
  18461. * @param target Defines the new target as a Vector or a mesh
  18462. */
  18463. setTarget(target: Vector3): void;
  18464. /**
  18465. * Defines the target point of the camera.
  18466. * The camera looks towards it form the radius distance.
  18467. */
  18468. get target(): Vector3;
  18469. set target(value: Vector3);
  18470. /**
  18471. * Return the current target position of the camera. This value is expressed in local space.
  18472. * @returns the target position
  18473. */
  18474. getTarget(): Vector3;
  18475. /** @hidden */
  18476. _decideIfNeedsToMove(): boolean;
  18477. /** @hidden */
  18478. _updatePosition(): void;
  18479. /** @hidden */
  18480. _checkInputs(): void;
  18481. protected _updateCameraRotationMatrix(): void;
  18482. /**
  18483. * 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)
  18484. * @returns the current camera
  18485. */
  18486. private _rotateUpVectorWithCameraRotationMatrix;
  18487. private _cachedRotationZ;
  18488. private _cachedQuaternionRotationZ;
  18489. /** @hidden */
  18490. _getViewMatrix(): Matrix;
  18491. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18492. /**
  18493. * @hidden
  18494. */
  18495. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18496. /**
  18497. * @hidden
  18498. */
  18499. _updateRigCameras(): void;
  18500. private _getRigCamPositionAndTarget;
  18501. /**
  18502. * Gets the current object class name.
  18503. * @return the class name
  18504. */
  18505. getClassName(): string;
  18506. }
  18507. }
  18508. declare module BABYLON {
  18509. /**
  18510. * Gather the list of keyboard event types as constants.
  18511. */
  18512. export class KeyboardEventTypes {
  18513. /**
  18514. * The keydown event is fired when a key becomes active (pressed).
  18515. */
  18516. static readonly KEYDOWN: number;
  18517. /**
  18518. * The keyup event is fired when a key has been released.
  18519. */
  18520. static readonly KEYUP: number;
  18521. }
  18522. /**
  18523. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18524. */
  18525. export class KeyboardInfo {
  18526. /**
  18527. * Defines the type of event (KeyboardEventTypes)
  18528. */
  18529. type: number;
  18530. /**
  18531. * Defines the related dom event
  18532. */
  18533. event: KeyboardEvent;
  18534. /**
  18535. * Instantiates a new keyboard info.
  18536. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18537. * @param type Defines the type of event (KeyboardEventTypes)
  18538. * @param event Defines the related dom event
  18539. */
  18540. constructor(
  18541. /**
  18542. * Defines the type of event (KeyboardEventTypes)
  18543. */
  18544. type: number,
  18545. /**
  18546. * Defines the related dom event
  18547. */
  18548. event: KeyboardEvent);
  18549. }
  18550. /**
  18551. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18552. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18553. */
  18554. export class KeyboardInfoPre extends KeyboardInfo {
  18555. /**
  18556. * Defines the type of event (KeyboardEventTypes)
  18557. */
  18558. type: number;
  18559. /**
  18560. * Defines the related dom event
  18561. */
  18562. event: KeyboardEvent;
  18563. /**
  18564. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18565. */
  18566. skipOnPointerObservable: boolean;
  18567. /**
  18568. * Instantiates a new keyboard pre info.
  18569. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18570. * @param type Defines the type of event (KeyboardEventTypes)
  18571. * @param event Defines the related dom event
  18572. */
  18573. constructor(
  18574. /**
  18575. * Defines the type of event (KeyboardEventTypes)
  18576. */
  18577. type: number,
  18578. /**
  18579. * Defines the related dom event
  18580. */
  18581. event: KeyboardEvent);
  18582. }
  18583. }
  18584. declare module BABYLON {
  18585. /**
  18586. * Manage the keyboard inputs to control the movement of a free camera.
  18587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18588. */
  18589. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18590. /**
  18591. * Defines the camera the input is attached to.
  18592. */
  18593. camera: FreeCamera;
  18594. /**
  18595. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18596. */
  18597. keysUp: number[];
  18598. /**
  18599. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18600. */
  18601. keysUpward: number[];
  18602. /**
  18603. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18604. */
  18605. keysDown: number[];
  18606. /**
  18607. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18608. */
  18609. keysDownward: number[];
  18610. /**
  18611. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18612. */
  18613. keysLeft: number[];
  18614. /**
  18615. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18616. */
  18617. keysRight: number[];
  18618. private _keys;
  18619. private _onCanvasBlurObserver;
  18620. private _onKeyboardObserver;
  18621. private _engine;
  18622. private _scene;
  18623. /**
  18624. * Attach the input controls to a specific dom element to get the input from.
  18625. * @param element Defines the element the controls should be listened from
  18626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18627. */
  18628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18629. /**
  18630. * Detach the current controls from the specified dom element.
  18631. * @param element Defines the element to stop listening the inputs from
  18632. */
  18633. detachControl(element: Nullable<HTMLElement>): void;
  18634. /**
  18635. * Update the current camera state depending on the inputs that have been used this frame.
  18636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18637. */
  18638. checkInputs(): void;
  18639. /**
  18640. * Gets the class name of the current intput.
  18641. * @returns the class name
  18642. */
  18643. getClassName(): string;
  18644. /** @hidden */
  18645. _onLostFocus(): void;
  18646. /**
  18647. * Get the friendly name associated with the input class.
  18648. * @returns the input friendly name
  18649. */
  18650. getSimpleName(): string;
  18651. }
  18652. }
  18653. declare module BABYLON {
  18654. /**
  18655. * Gather the list of pointer event types as constants.
  18656. */
  18657. export class PointerEventTypes {
  18658. /**
  18659. * 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.
  18660. */
  18661. static readonly POINTERDOWN: number;
  18662. /**
  18663. * The pointerup event is fired when a pointer is no longer active.
  18664. */
  18665. static readonly POINTERUP: number;
  18666. /**
  18667. * The pointermove event is fired when a pointer changes coordinates.
  18668. */
  18669. static readonly POINTERMOVE: number;
  18670. /**
  18671. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18672. */
  18673. static readonly POINTERWHEEL: number;
  18674. /**
  18675. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18676. */
  18677. static readonly POINTERPICK: number;
  18678. /**
  18679. * The pointertap event is fired when a the object has been touched and released without drag.
  18680. */
  18681. static readonly POINTERTAP: number;
  18682. /**
  18683. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18684. */
  18685. static readonly POINTERDOUBLETAP: number;
  18686. }
  18687. /**
  18688. * Base class of pointer info types.
  18689. */
  18690. export class PointerInfoBase {
  18691. /**
  18692. * Defines the type of event (PointerEventTypes)
  18693. */
  18694. type: number;
  18695. /**
  18696. * Defines the related dom event
  18697. */
  18698. event: PointerEvent | MouseWheelEvent;
  18699. /**
  18700. * Instantiates the base class of pointers info.
  18701. * @param type Defines the type of event (PointerEventTypes)
  18702. * @param event Defines the related dom event
  18703. */
  18704. constructor(
  18705. /**
  18706. * Defines the type of event (PointerEventTypes)
  18707. */
  18708. type: number,
  18709. /**
  18710. * Defines the related dom event
  18711. */
  18712. event: PointerEvent | MouseWheelEvent);
  18713. }
  18714. /**
  18715. * This class is used to store pointer related info for the onPrePointerObservable event.
  18716. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18717. */
  18718. export class PointerInfoPre extends PointerInfoBase {
  18719. /**
  18720. * Ray from a pointer if availible (eg. 6dof controller)
  18721. */
  18722. ray: Nullable<Ray>;
  18723. /**
  18724. * Defines the local position of the pointer on the canvas.
  18725. */
  18726. localPosition: Vector2;
  18727. /**
  18728. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18729. */
  18730. skipOnPointerObservable: boolean;
  18731. /**
  18732. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18733. * @param type Defines the type of event (PointerEventTypes)
  18734. * @param event Defines the related dom event
  18735. * @param localX Defines the local x coordinates of the pointer when the event occured
  18736. * @param localY Defines the local y coordinates of the pointer when the event occured
  18737. */
  18738. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18739. }
  18740. /**
  18741. * This type contains all the data related to a pointer event in Babylon.js.
  18742. * 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.
  18743. */
  18744. export class PointerInfo extends PointerInfoBase {
  18745. /**
  18746. * Defines the picking info associated to the info (if any)\
  18747. */
  18748. pickInfo: Nullable<PickingInfo>;
  18749. /**
  18750. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18751. * @param type Defines the type of event (PointerEventTypes)
  18752. * @param event Defines the related dom event
  18753. * @param pickInfo Defines the picking info associated to the info (if any)\
  18754. */
  18755. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18756. /**
  18757. * Defines the picking info associated to the info (if any)\
  18758. */
  18759. pickInfo: Nullable<PickingInfo>);
  18760. }
  18761. /**
  18762. * Data relating to a touch event on the screen.
  18763. */
  18764. export interface PointerTouch {
  18765. /**
  18766. * X coordinate of touch.
  18767. */
  18768. x: number;
  18769. /**
  18770. * Y coordinate of touch.
  18771. */
  18772. y: number;
  18773. /**
  18774. * Id of touch. Unique for each finger.
  18775. */
  18776. pointerId: number;
  18777. /**
  18778. * Event type passed from DOM.
  18779. */
  18780. type: any;
  18781. }
  18782. }
  18783. declare module BABYLON {
  18784. /**
  18785. * Manage the mouse inputs to control the movement of a free camera.
  18786. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18787. */
  18788. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18789. /**
  18790. * Define if touch is enabled in the mouse input
  18791. */
  18792. touchEnabled: boolean;
  18793. /**
  18794. * Defines the camera the input is attached to.
  18795. */
  18796. camera: FreeCamera;
  18797. /**
  18798. * Defines the buttons associated with the input to handle camera move.
  18799. */
  18800. buttons: number[];
  18801. /**
  18802. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18803. */
  18804. angularSensibility: number;
  18805. private _pointerInput;
  18806. private _onMouseMove;
  18807. private _observer;
  18808. private previousPosition;
  18809. /**
  18810. * Observable for when a pointer move event occurs containing the move offset
  18811. */
  18812. onPointerMovedObservable: Observable<{
  18813. offsetX: number;
  18814. offsetY: number;
  18815. }>;
  18816. /**
  18817. * @hidden
  18818. * If the camera should be rotated automatically based on pointer movement
  18819. */
  18820. _allowCameraRotation: boolean;
  18821. /**
  18822. * Manage the mouse inputs to control the movement of a free camera.
  18823. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18824. * @param touchEnabled Defines if touch is enabled or not
  18825. */
  18826. constructor(
  18827. /**
  18828. * Define if touch is enabled in the mouse input
  18829. */
  18830. touchEnabled?: boolean);
  18831. /**
  18832. * Attach the input controls to a specific dom element to get the input from.
  18833. * @param element Defines the element the controls should be listened from
  18834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18835. */
  18836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18837. /**
  18838. * Called on JS contextmenu event.
  18839. * Override this method to provide functionality.
  18840. */
  18841. protected onContextMenu(evt: PointerEvent): void;
  18842. /**
  18843. * Detach the current controls from the specified dom element.
  18844. * @param element Defines the element to stop listening the inputs from
  18845. */
  18846. detachControl(element: Nullable<HTMLElement>): void;
  18847. /**
  18848. * Gets the class name of the current intput.
  18849. * @returns the class name
  18850. */
  18851. getClassName(): string;
  18852. /**
  18853. * Get the friendly name associated with the input class.
  18854. * @returns the input friendly name
  18855. */
  18856. getSimpleName(): string;
  18857. }
  18858. }
  18859. declare module BABYLON {
  18860. /**
  18861. * Manage the touch inputs to control the movement of a free camera.
  18862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18863. */
  18864. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18865. /**
  18866. * Define if mouse events can be treated as touch events
  18867. */
  18868. allowMouse: boolean;
  18869. /**
  18870. * Defines the camera the input is attached to.
  18871. */
  18872. camera: FreeCamera;
  18873. /**
  18874. * Defines the touch sensibility for rotation.
  18875. * The higher the faster.
  18876. */
  18877. touchAngularSensibility: number;
  18878. /**
  18879. * Defines the touch sensibility for move.
  18880. * The higher the faster.
  18881. */
  18882. touchMoveSensibility: number;
  18883. private _offsetX;
  18884. private _offsetY;
  18885. private _pointerPressed;
  18886. private _pointerInput;
  18887. private _observer;
  18888. private _onLostFocus;
  18889. /**
  18890. * Manage the touch inputs to control the movement of a free camera.
  18891. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18892. * @param allowMouse Defines if mouse events can be treated as touch events
  18893. */
  18894. constructor(
  18895. /**
  18896. * Define if mouse events can be treated as touch events
  18897. */
  18898. allowMouse?: boolean);
  18899. /**
  18900. * Attach the input controls to a specific dom element to get the input from.
  18901. * @param element Defines the element the controls should be listened from
  18902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18903. */
  18904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18905. /**
  18906. * Detach the current controls from the specified dom element.
  18907. * @param element Defines the element to stop listening the inputs from
  18908. */
  18909. detachControl(element: Nullable<HTMLElement>): void;
  18910. /**
  18911. * Update the current camera state depending on the inputs that have been used this frame.
  18912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18913. */
  18914. checkInputs(): void;
  18915. /**
  18916. * Gets the class name of the current intput.
  18917. * @returns the class name
  18918. */
  18919. getClassName(): string;
  18920. /**
  18921. * Get the friendly name associated with the input class.
  18922. * @returns the input friendly name
  18923. */
  18924. getSimpleName(): string;
  18925. }
  18926. }
  18927. declare module BABYLON {
  18928. /**
  18929. * Default Inputs manager for the FreeCamera.
  18930. * It groups all the default supported inputs for ease of use.
  18931. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18932. */
  18933. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18934. /**
  18935. * @hidden
  18936. */
  18937. _mouseInput: Nullable<FreeCameraMouseInput>;
  18938. /**
  18939. * Instantiates a new FreeCameraInputsManager.
  18940. * @param camera Defines the camera the inputs belong to
  18941. */
  18942. constructor(camera: FreeCamera);
  18943. /**
  18944. * Add keyboard input support to the input manager.
  18945. * @returns the current input manager
  18946. */
  18947. addKeyboard(): FreeCameraInputsManager;
  18948. /**
  18949. * Add mouse input support to the input manager.
  18950. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18951. * @returns the current input manager
  18952. */
  18953. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18954. /**
  18955. * Removes the mouse input support from the manager
  18956. * @returns the current input manager
  18957. */
  18958. removeMouse(): FreeCameraInputsManager;
  18959. /**
  18960. * Add touch input support to the input manager.
  18961. * @returns the current input manager
  18962. */
  18963. addTouch(): FreeCameraInputsManager;
  18964. /**
  18965. * Remove all attached input methods from a camera
  18966. */
  18967. clear(): void;
  18968. }
  18969. }
  18970. declare module BABYLON {
  18971. /**
  18972. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18973. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18974. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18975. */
  18976. export class FreeCamera extends TargetCamera {
  18977. /**
  18978. * Define the collision ellipsoid of the camera.
  18979. * This is helpful to simulate a camera body like the player body around the camera
  18980. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18981. */
  18982. ellipsoid: Vector3;
  18983. /**
  18984. * Define an offset for the position of the ellipsoid around the camera.
  18985. * This can be helpful to determine the center of the body near the gravity center of the body
  18986. * instead of its head.
  18987. */
  18988. ellipsoidOffset: Vector3;
  18989. /**
  18990. * Enable or disable collisions of the camera with the rest of the scene objects.
  18991. */
  18992. checkCollisions: boolean;
  18993. /**
  18994. * Enable or disable gravity on the camera.
  18995. */
  18996. applyGravity: boolean;
  18997. /**
  18998. * Define the input manager associated to the camera.
  18999. */
  19000. inputs: FreeCameraInputsManager;
  19001. /**
  19002. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19003. * Higher values reduce sensitivity.
  19004. */
  19005. get angularSensibility(): number;
  19006. /**
  19007. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19008. * Higher values reduce sensitivity.
  19009. */
  19010. set angularSensibility(value: number);
  19011. /**
  19012. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19013. */
  19014. get keysUp(): number[];
  19015. set keysUp(value: number[]);
  19016. /**
  19017. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19018. */
  19019. get keysUpward(): number[];
  19020. set keysUpward(value: number[]);
  19021. /**
  19022. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19023. */
  19024. get keysDown(): number[];
  19025. set keysDown(value: number[]);
  19026. /**
  19027. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19028. */
  19029. get keysDownward(): number[];
  19030. set keysDownward(value: number[]);
  19031. /**
  19032. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19033. */
  19034. get keysLeft(): number[];
  19035. set keysLeft(value: number[]);
  19036. /**
  19037. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19038. */
  19039. get keysRight(): number[];
  19040. set keysRight(value: number[]);
  19041. /**
  19042. * Event raised when the camera collide with a mesh in the scene.
  19043. */
  19044. onCollide: (collidedMesh: AbstractMesh) => void;
  19045. private _collider;
  19046. private _needMoveForGravity;
  19047. private _oldPosition;
  19048. private _diffPosition;
  19049. private _newPosition;
  19050. /** @hidden */
  19051. _localDirection: Vector3;
  19052. /** @hidden */
  19053. _transformedDirection: Vector3;
  19054. /**
  19055. * Instantiates a Free Camera.
  19056. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19057. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19058. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19059. * @param name Define the name of the camera in the scene
  19060. * @param position Define the start position of the camera in the scene
  19061. * @param scene Define the scene the camera belongs to
  19062. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19063. */
  19064. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19065. /**
  19066. * Attached controls to the current camera.
  19067. * @param element Defines the element the controls should be listened from
  19068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19069. */
  19070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19071. /**
  19072. * Detach the current controls from the camera.
  19073. * The camera will stop reacting to inputs.
  19074. * @param element Defines the element to stop listening the inputs from
  19075. */
  19076. detachControl(element: HTMLElement): void;
  19077. private _collisionMask;
  19078. /**
  19079. * Define a collision mask to limit the list of object the camera can collide with
  19080. */
  19081. get collisionMask(): number;
  19082. set collisionMask(mask: number);
  19083. /** @hidden */
  19084. _collideWithWorld(displacement: Vector3): void;
  19085. private _onCollisionPositionChange;
  19086. /** @hidden */
  19087. _checkInputs(): void;
  19088. /** @hidden */
  19089. _decideIfNeedsToMove(): boolean;
  19090. /** @hidden */
  19091. _updatePosition(): void;
  19092. /**
  19093. * Destroy the camera and release the current resources hold by it.
  19094. */
  19095. dispose(): void;
  19096. /**
  19097. * Gets the current object class name.
  19098. * @return the class name
  19099. */
  19100. getClassName(): string;
  19101. }
  19102. }
  19103. declare module BABYLON {
  19104. /**
  19105. * Represents a gamepad control stick position
  19106. */
  19107. export class StickValues {
  19108. /**
  19109. * The x component of the control stick
  19110. */
  19111. x: number;
  19112. /**
  19113. * The y component of the control stick
  19114. */
  19115. y: number;
  19116. /**
  19117. * Initializes the gamepad x and y control stick values
  19118. * @param x The x component of the gamepad control stick value
  19119. * @param y The y component of the gamepad control stick value
  19120. */
  19121. constructor(
  19122. /**
  19123. * The x component of the control stick
  19124. */
  19125. x: number,
  19126. /**
  19127. * The y component of the control stick
  19128. */
  19129. y: number);
  19130. }
  19131. /**
  19132. * An interface which manages callbacks for gamepad button changes
  19133. */
  19134. export interface GamepadButtonChanges {
  19135. /**
  19136. * Called when a gamepad has been changed
  19137. */
  19138. changed: boolean;
  19139. /**
  19140. * Called when a gamepad press event has been triggered
  19141. */
  19142. pressChanged: boolean;
  19143. /**
  19144. * Called when a touch event has been triggered
  19145. */
  19146. touchChanged: boolean;
  19147. /**
  19148. * Called when a value has changed
  19149. */
  19150. valueChanged: boolean;
  19151. }
  19152. /**
  19153. * Represents a gamepad
  19154. */
  19155. export class Gamepad {
  19156. /**
  19157. * The id of the gamepad
  19158. */
  19159. id: string;
  19160. /**
  19161. * The index of the gamepad
  19162. */
  19163. index: number;
  19164. /**
  19165. * The browser gamepad
  19166. */
  19167. browserGamepad: any;
  19168. /**
  19169. * Specifies what type of gamepad this represents
  19170. */
  19171. type: number;
  19172. private _leftStick;
  19173. private _rightStick;
  19174. /** @hidden */
  19175. _isConnected: boolean;
  19176. private _leftStickAxisX;
  19177. private _leftStickAxisY;
  19178. private _rightStickAxisX;
  19179. private _rightStickAxisY;
  19180. /**
  19181. * Triggered when the left control stick has been changed
  19182. */
  19183. private _onleftstickchanged;
  19184. /**
  19185. * Triggered when the right control stick has been changed
  19186. */
  19187. private _onrightstickchanged;
  19188. /**
  19189. * Represents a gamepad controller
  19190. */
  19191. static GAMEPAD: number;
  19192. /**
  19193. * Represents a generic controller
  19194. */
  19195. static GENERIC: number;
  19196. /**
  19197. * Represents an XBox controller
  19198. */
  19199. static XBOX: number;
  19200. /**
  19201. * Represents a pose-enabled controller
  19202. */
  19203. static POSE_ENABLED: number;
  19204. /**
  19205. * Represents an Dual Shock controller
  19206. */
  19207. static DUALSHOCK: number;
  19208. /**
  19209. * Specifies whether the left control stick should be Y-inverted
  19210. */
  19211. protected _invertLeftStickY: boolean;
  19212. /**
  19213. * Specifies if the gamepad has been connected
  19214. */
  19215. get isConnected(): boolean;
  19216. /**
  19217. * Initializes the gamepad
  19218. * @param id The id of the gamepad
  19219. * @param index The index of the gamepad
  19220. * @param browserGamepad The browser gamepad
  19221. * @param leftStickX The x component of the left joystick
  19222. * @param leftStickY The y component of the left joystick
  19223. * @param rightStickX The x component of the right joystick
  19224. * @param rightStickY The y component of the right joystick
  19225. */
  19226. constructor(
  19227. /**
  19228. * The id of the gamepad
  19229. */
  19230. id: string,
  19231. /**
  19232. * The index of the gamepad
  19233. */
  19234. index: number,
  19235. /**
  19236. * The browser gamepad
  19237. */
  19238. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19239. /**
  19240. * Callback triggered when the left joystick has changed
  19241. * @param callback
  19242. */
  19243. onleftstickchanged(callback: (values: StickValues) => void): void;
  19244. /**
  19245. * Callback triggered when the right joystick has changed
  19246. * @param callback
  19247. */
  19248. onrightstickchanged(callback: (values: StickValues) => void): void;
  19249. /**
  19250. * Gets the left joystick
  19251. */
  19252. get leftStick(): StickValues;
  19253. /**
  19254. * Sets the left joystick values
  19255. */
  19256. set leftStick(newValues: StickValues);
  19257. /**
  19258. * Gets the right joystick
  19259. */
  19260. get rightStick(): StickValues;
  19261. /**
  19262. * Sets the right joystick value
  19263. */
  19264. set rightStick(newValues: StickValues);
  19265. /**
  19266. * Updates the gamepad joystick positions
  19267. */
  19268. update(): void;
  19269. /**
  19270. * Disposes the gamepad
  19271. */
  19272. dispose(): void;
  19273. }
  19274. /**
  19275. * Represents a generic gamepad
  19276. */
  19277. export class GenericPad extends Gamepad {
  19278. private _buttons;
  19279. private _onbuttondown;
  19280. private _onbuttonup;
  19281. /**
  19282. * Observable triggered when a button has been pressed
  19283. */
  19284. onButtonDownObservable: Observable<number>;
  19285. /**
  19286. * Observable triggered when a button has been released
  19287. */
  19288. onButtonUpObservable: Observable<number>;
  19289. /**
  19290. * Callback triggered when a button has been pressed
  19291. * @param callback Called when a button has been pressed
  19292. */
  19293. onbuttondown(callback: (buttonPressed: number) => void): void;
  19294. /**
  19295. * Callback triggered when a button has been released
  19296. * @param callback Called when a button has been released
  19297. */
  19298. onbuttonup(callback: (buttonReleased: number) => void): void;
  19299. /**
  19300. * Initializes the generic gamepad
  19301. * @param id The id of the generic gamepad
  19302. * @param index The index of the generic gamepad
  19303. * @param browserGamepad The browser gamepad
  19304. */
  19305. constructor(id: string, index: number, browserGamepad: any);
  19306. private _setButtonValue;
  19307. /**
  19308. * Updates the generic gamepad
  19309. */
  19310. update(): void;
  19311. /**
  19312. * Disposes the generic gamepad
  19313. */
  19314. dispose(): void;
  19315. }
  19316. }
  19317. declare module BABYLON {
  19318. /**
  19319. * Defines the types of pose enabled controllers that are supported
  19320. */
  19321. export enum PoseEnabledControllerType {
  19322. /**
  19323. * HTC Vive
  19324. */
  19325. VIVE = 0,
  19326. /**
  19327. * Oculus Rift
  19328. */
  19329. OCULUS = 1,
  19330. /**
  19331. * Windows mixed reality
  19332. */
  19333. WINDOWS = 2,
  19334. /**
  19335. * Samsung gear VR
  19336. */
  19337. GEAR_VR = 3,
  19338. /**
  19339. * Google Daydream
  19340. */
  19341. DAYDREAM = 4,
  19342. /**
  19343. * Generic
  19344. */
  19345. GENERIC = 5
  19346. }
  19347. /**
  19348. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19349. */
  19350. export interface MutableGamepadButton {
  19351. /**
  19352. * Value of the button/trigger
  19353. */
  19354. value: number;
  19355. /**
  19356. * If the button/trigger is currently touched
  19357. */
  19358. touched: boolean;
  19359. /**
  19360. * If the button/trigger is currently pressed
  19361. */
  19362. pressed: boolean;
  19363. }
  19364. /**
  19365. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19366. * @hidden
  19367. */
  19368. export interface ExtendedGamepadButton extends GamepadButton {
  19369. /**
  19370. * If the button/trigger is currently pressed
  19371. */
  19372. readonly pressed: boolean;
  19373. /**
  19374. * If the button/trigger is currently touched
  19375. */
  19376. readonly touched: boolean;
  19377. /**
  19378. * Value of the button/trigger
  19379. */
  19380. readonly value: number;
  19381. }
  19382. /** @hidden */
  19383. export interface _GamePadFactory {
  19384. /**
  19385. * Returns whether or not the current gamepad can be created for this type of controller.
  19386. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19387. * @returns true if it can be created, otherwise false
  19388. */
  19389. canCreate(gamepadInfo: any): boolean;
  19390. /**
  19391. * Creates a new instance of the Gamepad.
  19392. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19393. * @returns the new gamepad instance
  19394. */
  19395. create(gamepadInfo: any): Gamepad;
  19396. }
  19397. /**
  19398. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19399. */
  19400. export class PoseEnabledControllerHelper {
  19401. /** @hidden */
  19402. static _ControllerFactories: _GamePadFactory[];
  19403. /** @hidden */
  19404. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19405. /**
  19406. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19407. * @param vrGamepad the gamepad to initialized
  19408. * @returns a vr controller of the type the gamepad identified as
  19409. */
  19410. static InitiateController(vrGamepad: any): Gamepad;
  19411. }
  19412. /**
  19413. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19414. */
  19415. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19416. /**
  19417. * If the controller is used in a webXR session
  19418. */
  19419. isXR: boolean;
  19420. private _deviceRoomPosition;
  19421. private _deviceRoomRotationQuaternion;
  19422. /**
  19423. * The device position in babylon space
  19424. */
  19425. devicePosition: Vector3;
  19426. /**
  19427. * The device rotation in babylon space
  19428. */
  19429. deviceRotationQuaternion: Quaternion;
  19430. /**
  19431. * The scale factor of the device in babylon space
  19432. */
  19433. deviceScaleFactor: number;
  19434. /**
  19435. * (Likely devicePosition should be used instead) The device position in its room space
  19436. */
  19437. position: Vector3;
  19438. /**
  19439. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19440. */
  19441. rotationQuaternion: Quaternion;
  19442. /**
  19443. * The type of controller (Eg. Windows mixed reality)
  19444. */
  19445. controllerType: PoseEnabledControllerType;
  19446. protected _calculatedPosition: Vector3;
  19447. private _calculatedRotation;
  19448. /**
  19449. * The raw pose from the device
  19450. */
  19451. rawPose: DevicePose;
  19452. private _trackPosition;
  19453. private _maxRotationDistFromHeadset;
  19454. private _draggedRoomRotation;
  19455. /**
  19456. * @hidden
  19457. */
  19458. _disableTrackPosition(fixedPosition: Vector3): void;
  19459. /**
  19460. * Internal, the mesh attached to the controller
  19461. * @hidden
  19462. */
  19463. _mesh: Nullable<AbstractMesh>;
  19464. private _poseControlledCamera;
  19465. private _leftHandSystemQuaternion;
  19466. /**
  19467. * Internal, matrix used to convert room space to babylon space
  19468. * @hidden
  19469. */
  19470. _deviceToWorld: Matrix;
  19471. /**
  19472. * Node to be used when casting a ray from the controller
  19473. * @hidden
  19474. */
  19475. _pointingPoseNode: Nullable<TransformNode>;
  19476. /**
  19477. * Name of the child mesh that can be used to cast a ray from the controller
  19478. */
  19479. static readonly POINTING_POSE: string;
  19480. /**
  19481. * Creates a new PoseEnabledController from a gamepad
  19482. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19483. */
  19484. constructor(browserGamepad: any);
  19485. private _workingMatrix;
  19486. /**
  19487. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19488. */
  19489. update(): void;
  19490. /**
  19491. * Updates only the pose device and mesh without doing any button event checking
  19492. */
  19493. protected _updatePoseAndMesh(): void;
  19494. /**
  19495. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19496. * @param poseData raw pose fromthe device
  19497. */
  19498. updateFromDevice(poseData: DevicePose): void;
  19499. /**
  19500. * @hidden
  19501. */
  19502. _meshAttachedObservable: Observable<AbstractMesh>;
  19503. /**
  19504. * Attaches a mesh to the controller
  19505. * @param mesh the mesh to be attached
  19506. */
  19507. attachToMesh(mesh: AbstractMesh): void;
  19508. /**
  19509. * Attaches the controllers mesh to a camera
  19510. * @param camera the camera the mesh should be attached to
  19511. */
  19512. attachToPoseControlledCamera(camera: TargetCamera): void;
  19513. /**
  19514. * Disposes of the controller
  19515. */
  19516. dispose(): void;
  19517. /**
  19518. * The mesh that is attached to the controller
  19519. */
  19520. get mesh(): Nullable<AbstractMesh>;
  19521. /**
  19522. * Gets the ray of the controller in the direction the controller is pointing
  19523. * @param length the length the resulting ray should be
  19524. * @returns a ray in the direction the controller is pointing
  19525. */
  19526. getForwardRay(length?: number): Ray;
  19527. }
  19528. }
  19529. declare module BABYLON {
  19530. /**
  19531. * Defines the WebVRController object that represents controllers tracked in 3D space
  19532. */
  19533. export abstract class WebVRController extends PoseEnabledController {
  19534. /**
  19535. * Internal, the default controller model for the controller
  19536. */
  19537. protected _defaultModel: Nullable<AbstractMesh>;
  19538. /**
  19539. * Fired when the trigger state has changed
  19540. */
  19541. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19542. /**
  19543. * Fired when the main button state has changed
  19544. */
  19545. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19546. /**
  19547. * Fired when the secondary button state has changed
  19548. */
  19549. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19550. /**
  19551. * Fired when the pad state has changed
  19552. */
  19553. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19554. /**
  19555. * Fired when controllers stick values have changed
  19556. */
  19557. onPadValuesChangedObservable: Observable<StickValues>;
  19558. /**
  19559. * Array of button availible on the controller
  19560. */
  19561. protected _buttons: Array<MutableGamepadButton>;
  19562. private _onButtonStateChange;
  19563. /**
  19564. * Fired when a controller button's state has changed
  19565. * @param callback the callback containing the button that was modified
  19566. */
  19567. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19568. /**
  19569. * X and Y axis corresponding to the controllers joystick
  19570. */
  19571. pad: StickValues;
  19572. /**
  19573. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19574. */
  19575. hand: string;
  19576. /**
  19577. * The default controller model for the controller
  19578. */
  19579. get defaultModel(): Nullable<AbstractMesh>;
  19580. /**
  19581. * Creates a new WebVRController from a gamepad
  19582. * @param vrGamepad the gamepad that the WebVRController should be created from
  19583. */
  19584. constructor(vrGamepad: any);
  19585. /**
  19586. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19587. */
  19588. update(): void;
  19589. /**
  19590. * Function to be called when a button is modified
  19591. */
  19592. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19593. /**
  19594. * Loads a mesh and attaches it to the controller
  19595. * @param scene the scene the mesh should be added to
  19596. * @param meshLoaded callback for when the mesh has been loaded
  19597. */
  19598. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19599. private _setButtonValue;
  19600. private _changes;
  19601. private _checkChanges;
  19602. /**
  19603. * Disposes of th webVRCOntroller
  19604. */
  19605. dispose(): void;
  19606. }
  19607. }
  19608. declare module BABYLON {
  19609. /**
  19610. * The HemisphericLight simulates the ambient environment light,
  19611. * so the passed direction is the light reflection direction, not the incoming direction.
  19612. */
  19613. export class HemisphericLight extends Light {
  19614. /**
  19615. * The groundColor is the light in the opposite direction to the one specified during creation.
  19616. * 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.
  19617. */
  19618. groundColor: Color3;
  19619. /**
  19620. * The light reflection direction, not the incoming direction.
  19621. */
  19622. direction: Vector3;
  19623. /**
  19624. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19625. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19626. * The HemisphericLight can't cast shadows.
  19627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19628. * @param name The friendly name of the light
  19629. * @param direction The direction of the light reflection
  19630. * @param scene The scene the light belongs to
  19631. */
  19632. constructor(name: string, direction: Vector3, scene: Scene);
  19633. protected _buildUniformLayout(): void;
  19634. /**
  19635. * Returns the string "HemisphericLight".
  19636. * @return The class name
  19637. */
  19638. getClassName(): string;
  19639. /**
  19640. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19641. * Returns the updated direction.
  19642. * @param target The target the direction should point to
  19643. * @return The computed direction
  19644. */
  19645. setDirectionToTarget(target: Vector3): Vector3;
  19646. /**
  19647. * Returns the shadow generator associated to the light.
  19648. * @returns Always null for hemispheric lights because it does not support shadows.
  19649. */
  19650. getShadowGenerator(): Nullable<IShadowGenerator>;
  19651. /**
  19652. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19653. * @param effect The effect to update
  19654. * @param lightIndex The index of the light in the effect to update
  19655. * @returns The hemispheric light
  19656. */
  19657. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19658. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19659. /**
  19660. * Computes the world matrix of the node
  19661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19662. * @param useWasUpdatedFlag defines a reserved property
  19663. * @returns the world matrix
  19664. */
  19665. computeWorldMatrix(): Matrix;
  19666. /**
  19667. * Returns the integer 3.
  19668. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19669. */
  19670. getTypeID(): number;
  19671. /**
  19672. * Prepares the list of defines specific to the light type.
  19673. * @param defines the list of defines
  19674. * @param lightIndex defines the index of the light for the effect
  19675. */
  19676. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19677. }
  19678. }
  19679. declare module BABYLON {
  19680. /** @hidden */
  19681. export var vrMultiviewToSingleviewPixelShader: {
  19682. name: string;
  19683. shader: string;
  19684. };
  19685. }
  19686. declare module BABYLON {
  19687. /**
  19688. * Renders to multiple views with a single draw call
  19689. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19690. */
  19691. export class MultiviewRenderTarget extends RenderTargetTexture {
  19692. /**
  19693. * Creates a multiview render target
  19694. * @param scene scene used with the render target
  19695. * @param size the size of the render target (used for each view)
  19696. */
  19697. constructor(scene: Scene, size?: number | {
  19698. width: number;
  19699. height: number;
  19700. } | {
  19701. ratio: number;
  19702. });
  19703. /**
  19704. * @hidden
  19705. * @param faceIndex the face index, if its a cube texture
  19706. */
  19707. _bindFrameBuffer(faceIndex?: number): void;
  19708. /**
  19709. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19710. * @returns the view count
  19711. */
  19712. getViewCount(): number;
  19713. }
  19714. }
  19715. declare module BABYLON {
  19716. interface Engine {
  19717. /**
  19718. * Creates a new multiview render target
  19719. * @param width defines the width of the texture
  19720. * @param height defines the height of the texture
  19721. * @returns the created multiview texture
  19722. */
  19723. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19724. /**
  19725. * Binds a multiview framebuffer to be drawn to
  19726. * @param multiviewTexture texture to bind
  19727. */
  19728. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19729. }
  19730. interface Camera {
  19731. /**
  19732. * @hidden
  19733. * 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)
  19734. */
  19735. _useMultiviewToSingleView: boolean;
  19736. /**
  19737. * @hidden
  19738. * 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)
  19739. */
  19740. _multiviewTexture: Nullable<RenderTargetTexture>;
  19741. /**
  19742. * @hidden
  19743. * ensures the multiview texture of the camera exists and has the specified width/height
  19744. * @param width height to set on the multiview texture
  19745. * @param height width to set on the multiview texture
  19746. */
  19747. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19748. }
  19749. interface Scene {
  19750. /** @hidden */
  19751. _transformMatrixR: Matrix;
  19752. /** @hidden */
  19753. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19754. /** @hidden */
  19755. _createMultiviewUbo(): void;
  19756. /** @hidden */
  19757. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19758. /** @hidden */
  19759. _renderMultiviewToSingleView(camera: Camera): void;
  19760. }
  19761. }
  19762. declare module BABYLON {
  19763. /**
  19764. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19765. * This will not be used for webXR as it supports displaying texture arrays directly
  19766. */
  19767. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19768. /**
  19769. * Gets a string identifying the name of the class
  19770. * @returns "VRMultiviewToSingleviewPostProcess" string
  19771. */
  19772. getClassName(): string;
  19773. /**
  19774. * Initializes a VRMultiviewToSingleview
  19775. * @param name name of the post process
  19776. * @param camera camera to be applied to
  19777. * @param scaleFactor scaling factor to the size of the output texture
  19778. */
  19779. constructor(name: string, camera: Camera, scaleFactor: number);
  19780. }
  19781. }
  19782. declare module BABYLON {
  19783. /**
  19784. * Interface used to define additional presentation attributes
  19785. */
  19786. export interface IVRPresentationAttributes {
  19787. /**
  19788. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19789. */
  19790. highRefreshRate: boolean;
  19791. /**
  19792. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19793. */
  19794. foveationLevel: number;
  19795. }
  19796. interface Engine {
  19797. /** @hidden */
  19798. _vrDisplay: any;
  19799. /** @hidden */
  19800. _vrSupported: boolean;
  19801. /** @hidden */
  19802. _oldSize: Size;
  19803. /** @hidden */
  19804. _oldHardwareScaleFactor: number;
  19805. /** @hidden */
  19806. _vrExclusivePointerMode: boolean;
  19807. /** @hidden */
  19808. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19809. /** @hidden */
  19810. _onVRDisplayPointerRestricted: () => void;
  19811. /** @hidden */
  19812. _onVRDisplayPointerUnrestricted: () => void;
  19813. /** @hidden */
  19814. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19815. /** @hidden */
  19816. _onVrDisplayDisconnect: Nullable<() => void>;
  19817. /** @hidden */
  19818. _onVrDisplayPresentChange: Nullable<() => void>;
  19819. /**
  19820. * Observable signaled when VR display mode changes
  19821. */
  19822. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19823. /**
  19824. * Observable signaled when VR request present is complete
  19825. */
  19826. onVRRequestPresentComplete: Observable<boolean>;
  19827. /**
  19828. * Observable signaled when VR request present starts
  19829. */
  19830. onVRRequestPresentStart: Observable<Engine>;
  19831. /**
  19832. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19833. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19834. */
  19835. isInVRExclusivePointerMode: boolean;
  19836. /**
  19837. * Gets a boolean indicating if a webVR device was detected
  19838. * @returns true if a webVR device was detected
  19839. */
  19840. isVRDevicePresent(): boolean;
  19841. /**
  19842. * Gets the current webVR device
  19843. * @returns the current webVR device (or null)
  19844. */
  19845. getVRDevice(): any;
  19846. /**
  19847. * Initializes a webVR display and starts listening to display change events
  19848. * The onVRDisplayChangedObservable will be notified upon these changes
  19849. * @returns A promise containing a VRDisplay and if vr is supported
  19850. */
  19851. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19852. /** @hidden */
  19853. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19854. /**
  19855. * Gets or sets the presentation attributes used to configure VR rendering
  19856. */
  19857. vrPresentationAttributes?: IVRPresentationAttributes;
  19858. /**
  19859. * Call this function to switch to webVR mode
  19860. * Will do nothing if webVR is not supported or if there is no webVR device
  19861. * @param options the webvr options provided to the camera. mainly used for multiview
  19862. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19863. */
  19864. enableVR(options: WebVROptions): void;
  19865. /** @hidden */
  19866. _onVRFullScreenTriggered(): void;
  19867. }
  19868. }
  19869. declare module BABYLON {
  19870. /**
  19871. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19872. * IMPORTANT!! The data is right-hand data.
  19873. * @export
  19874. * @interface DevicePose
  19875. */
  19876. export interface DevicePose {
  19877. /**
  19878. * The position of the device, values in array are [x,y,z].
  19879. */
  19880. readonly position: Nullable<Float32Array>;
  19881. /**
  19882. * The linearVelocity of the device, values in array are [x,y,z].
  19883. */
  19884. readonly linearVelocity: Nullable<Float32Array>;
  19885. /**
  19886. * The linearAcceleration of the device, values in array are [x,y,z].
  19887. */
  19888. readonly linearAcceleration: Nullable<Float32Array>;
  19889. /**
  19890. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19891. */
  19892. readonly orientation: Nullable<Float32Array>;
  19893. /**
  19894. * The angularVelocity of the device, values in array are [x,y,z].
  19895. */
  19896. readonly angularVelocity: Nullable<Float32Array>;
  19897. /**
  19898. * The angularAcceleration of the device, values in array are [x,y,z].
  19899. */
  19900. readonly angularAcceleration: Nullable<Float32Array>;
  19901. }
  19902. /**
  19903. * Interface representing a pose controlled object in Babylon.
  19904. * A pose controlled object has both regular pose values as well as pose values
  19905. * from an external device such as a VR head mounted display
  19906. */
  19907. export interface PoseControlled {
  19908. /**
  19909. * The position of the object in babylon space.
  19910. */
  19911. position: Vector3;
  19912. /**
  19913. * The rotation quaternion of the object in babylon space.
  19914. */
  19915. rotationQuaternion: Quaternion;
  19916. /**
  19917. * The position of the device in babylon space.
  19918. */
  19919. devicePosition?: Vector3;
  19920. /**
  19921. * The rotation quaternion of the device in babylon space.
  19922. */
  19923. deviceRotationQuaternion: Quaternion;
  19924. /**
  19925. * The raw pose coming from the device.
  19926. */
  19927. rawPose: Nullable<DevicePose>;
  19928. /**
  19929. * The scale of the device to be used when translating from device space to babylon space.
  19930. */
  19931. deviceScaleFactor: number;
  19932. /**
  19933. * Updates the poseControlled values based on the input device pose.
  19934. * @param poseData the pose data to update the object with
  19935. */
  19936. updateFromDevice(poseData: DevicePose): void;
  19937. }
  19938. /**
  19939. * Set of options to customize the webVRCamera
  19940. */
  19941. export interface WebVROptions {
  19942. /**
  19943. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19944. */
  19945. trackPosition?: boolean;
  19946. /**
  19947. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19948. */
  19949. positionScale?: number;
  19950. /**
  19951. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19952. */
  19953. displayName?: string;
  19954. /**
  19955. * Should the native controller meshes be initialized. (default: true)
  19956. */
  19957. controllerMeshes?: boolean;
  19958. /**
  19959. * Creating a default HemiLight only on controllers. (default: true)
  19960. */
  19961. defaultLightingOnControllers?: boolean;
  19962. /**
  19963. * If you don't want to use the default VR button of the helper. (default: false)
  19964. */
  19965. useCustomVRButton?: boolean;
  19966. /**
  19967. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19968. */
  19969. customVRButton?: HTMLButtonElement;
  19970. /**
  19971. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19972. */
  19973. rayLength?: number;
  19974. /**
  19975. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19976. */
  19977. defaultHeight?: number;
  19978. /**
  19979. * If multiview should be used if availible (default: false)
  19980. */
  19981. useMultiview?: boolean;
  19982. }
  19983. /**
  19984. * This represents a WebVR camera.
  19985. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19986. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19987. */
  19988. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19989. private webVROptions;
  19990. /**
  19991. * @hidden
  19992. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19993. */
  19994. _vrDevice: any;
  19995. /**
  19996. * The rawPose of the vrDevice.
  19997. */
  19998. rawPose: Nullable<DevicePose>;
  19999. private _onVREnabled;
  20000. private _specsVersion;
  20001. private _attached;
  20002. private _frameData;
  20003. protected _descendants: Array<Node>;
  20004. private _deviceRoomPosition;
  20005. /** @hidden */
  20006. _deviceRoomRotationQuaternion: Quaternion;
  20007. private _standingMatrix;
  20008. /**
  20009. * Represents device position in babylon space.
  20010. */
  20011. devicePosition: Vector3;
  20012. /**
  20013. * Represents device rotation in babylon space.
  20014. */
  20015. deviceRotationQuaternion: Quaternion;
  20016. /**
  20017. * The scale of the device to be used when translating from device space to babylon space.
  20018. */
  20019. deviceScaleFactor: number;
  20020. private _deviceToWorld;
  20021. private _worldToDevice;
  20022. /**
  20023. * References to the webVR controllers for the vrDevice.
  20024. */
  20025. controllers: Array<WebVRController>;
  20026. /**
  20027. * Emits an event when a controller is attached.
  20028. */
  20029. onControllersAttachedObservable: Observable<WebVRController[]>;
  20030. /**
  20031. * Emits an event when a controller's mesh has been loaded;
  20032. */
  20033. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20034. /**
  20035. * Emits an event when the HMD's pose has been updated.
  20036. */
  20037. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20038. private _poseSet;
  20039. /**
  20040. * If the rig cameras be used as parent instead of this camera.
  20041. */
  20042. rigParenting: boolean;
  20043. private _lightOnControllers;
  20044. private _defaultHeight?;
  20045. /**
  20046. * Instantiates a WebVRFreeCamera.
  20047. * @param name The name of the WebVRFreeCamera
  20048. * @param position The starting anchor position for the camera
  20049. * @param scene The scene the camera belongs to
  20050. * @param webVROptions a set of customizable options for the webVRCamera
  20051. */
  20052. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20053. /**
  20054. * Gets the device distance from the ground in meters.
  20055. * @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.
  20056. */
  20057. deviceDistanceToRoomGround(): number;
  20058. /**
  20059. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20060. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20061. */
  20062. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20063. /**
  20064. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20065. * @returns A promise with a boolean set to if the standing matrix is supported.
  20066. */
  20067. useStandingMatrixAsync(): Promise<boolean>;
  20068. /**
  20069. * Disposes the camera
  20070. */
  20071. dispose(): void;
  20072. /**
  20073. * Gets a vrController by name.
  20074. * @param name The name of the controller to retreive
  20075. * @returns the controller matching the name specified or null if not found
  20076. */
  20077. getControllerByName(name: string): Nullable<WebVRController>;
  20078. private _leftController;
  20079. /**
  20080. * The controller corresponding to the users left hand.
  20081. */
  20082. get leftController(): Nullable<WebVRController>;
  20083. private _rightController;
  20084. /**
  20085. * The controller corresponding to the users right hand.
  20086. */
  20087. get rightController(): Nullable<WebVRController>;
  20088. /**
  20089. * Casts a ray forward from the vrCamera's gaze.
  20090. * @param length Length of the ray (default: 100)
  20091. * @returns the ray corresponding to the gaze
  20092. */
  20093. getForwardRay(length?: number): Ray;
  20094. /**
  20095. * @hidden
  20096. * Updates the camera based on device's frame data
  20097. */
  20098. _checkInputs(): void;
  20099. /**
  20100. * Updates the poseControlled values based on the input device pose.
  20101. * @param poseData Pose coming from the device
  20102. */
  20103. updateFromDevice(poseData: DevicePose): void;
  20104. private _htmlElementAttached;
  20105. private _detachIfAttached;
  20106. /**
  20107. * WebVR's attach control will start broadcasting frames to the device.
  20108. * Note that in certain browsers (chrome for example) this function must be called
  20109. * within a user-interaction callback. Example:
  20110. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20111. *
  20112. * @param element html element to attach the vrDevice to
  20113. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20114. */
  20115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20116. /**
  20117. * Detaches the camera from the html element and disables VR
  20118. *
  20119. * @param element html element to detach from
  20120. */
  20121. detachControl(element: HTMLElement): void;
  20122. /**
  20123. * @returns the name of this class
  20124. */
  20125. getClassName(): string;
  20126. /**
  20127. * Calls resetPose on the vrDisplay
  20128. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20129. */
  20130. resetToCurrentRotation(): void;
  20131. /**
  20132. * @hidden
  20133. * Updates the rig cameras (left and right eye)
  20134. */
  20135. _updateRigCameras(): void;
  20136. private _workingVector;
  20137. private _oneVector;
  20138. private _workingMatrix;
  20139. private updateCacheCalled;
  20140. private _correctPositionIfNotTrackPosition;
  20141. /**
  20142. * @hidden
  20143. * Updates the cached values of the camera
  20144. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20145. */
  20146. _updateCache(ignoreParentClass?: boolean): void;
  20147. /**
  20148. * @hidden
  20149. * Get current device position in babylon world
  20150. */
  20151. _computeDevicePosition(): void;
  20152. /**
  20153. * Updates the current device position and rotation in the babylon world
  20154. */
  20155. update(): void;
  20156. /**
  20157. * @hidden
  20158. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20159. * @returns an identity matrix
  20160. */
  20161. _getViewMatrix(): Matrix;
  20162. private _tmpMatrix;
  20163. /**
  20164. * This function is called by the two RIG cameras.
  20165. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20166. * @hidden
  20167. */
  20168. _getWebVRViewMatrix(): Matrix;
  20169. /** @hidden */
  20170. _getWebVRProjectionMatrix(): Matrix;
  20171. private _onGamepadConnectedObserver;
  20172. private _onGamepadDisconnectedObserver;
  20173. private _updateCacheWhenTrackingDisabledObserver;
  20174. /**
  20175. * Initializes the controllers and their meshes
  20176. */
  20177. initControllers(): void;
  20178. }
  20179. }
  20180. declare module BABYLON {
  20181. /**
  20182. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20183. *
  20184. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20185. *
  20186. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20187. */
  20188. export class MaterialHelper {
  20189. /**
  20190. * Bind the current view position to an effect.
  20191. * @param effect The effect to be bound
  20192. * @param scene The scene the eyes position is used from
  20193. * @param variableName name of the shader variable that will hold the eye position
  20194. */
  20195. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20196. /**
  20197. * Helps preparing the defines values about the UVs in used in the effect.
  20198. * UVs are shared as much as we can accross channels in the shaders.
  20199. * @param texture The texture we are preparing the UVs for
  20200. * @param defines The defines to update
  20201. * @param key The channel key "diffuse", "specular"... used in the shader
  20202. */
  20203. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20204. /**
  20205. * Binds a texture matrix value to its corrsponding uniform
  20206. * @param texture The texture to bind the matrix for
  20207. * @param uniformBuffer The uniform buffer receivin the data
  20208. * @param key The channel key "diffuse", "specular"... used in the shader
  20209. */
  20210. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20211. /**
  20212. * Gets the current status of the fog (should it be enabled?)
  20213. * @param mesh defines the mesh to evaluate for fog support
  20214. * @param scene defines the hosting scene
  20215. * @returns true if fog must be enabled
  20216. */
  20217. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20218. /**
  20219. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20220. * @param mesh defines the current mesh
  20221. * @param scene defines the current scene
  20222. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20223. * @param pointsCloud defines if point cloud rendering has to be turned on
  20224. * @param fogEnabled defines if fog has to be turned on
  20225. * @param alphaTest defines if alpha testing has to be turned on
  20226. * @param defines defines the current list of defines
  20227. */
  20228. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20229. /**
  20230. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20231. * @param scene defines the current scene
  20232. * @param engine defines the current engine
  20233. * @param defines specifies the list of active defines
  20234. * @param useInstances defines if instances have to be turned on
  20235. * @param useClipPlane defines if clip plane have to be turned on
  20236. * @param useInstances defines if instances have to be turned on
  20237. * @param useThinInstances defines if thin instances have to be turned on
  20238. */
  20239. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20240. /**
  20241. * Prepares the defines for bones
  20242. * @param mesh The mesh containing the geometry data we will draw
  20243. * @param defines The defines to update
  20244. */
  20245. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20246. /**
  20247. * Prepares the defines for morph targets
  20248. * @param mesh The mesh containing the geometry data we will draw
  20249. * @param defines The defines to update
  20250. */
  20251. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20252. /**
  20253. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20254. * @param mesh The mesh containing the geometry data we will draw
  20255. * @param defines The defines to update
  20256. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20257. * @param useBones Precise whether bones should be used or not (override mesh info)
  20258. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20259. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20260. * @returns false if defines are considered not dirty and have not been checked
  20261. */
  20262. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20263. /**
  20264. * Prepares the defines related to multiview
  20265. * @param scene The scene we are intending to draw
  20266. * @param defines The defines to update
  20267. */
  20268. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20269. /**
  20270. * Prepares the defines related to the prepass
  20271. * @param scene The scene we are intending to draw
  20272. * @param defines The defines to update
  20273. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20274. */
  20275. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20276. /**
  20277. * Prepares the defines related to the light information passed in parameter
  20278. * @param scene The scene we are intending to draw
  20279. * @param mesh The mesh the effect is compiling for
  20280. * @param light The light the effect is compiling for
  20281. * @param lightIndex The index of the light
  20282. * @param defines The defines to update
  20283. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20284. * @param state Defines the current state regarding what is needed (normals, etc...)
  20285. */
  20286. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20287. needNormals: boolean;
  20288. needRebuild: boolean;
  20289. shadowEnabled: boolean;
  20290. specularEnabled: boolean;
  20291. lightmapMode: boolean;
  20292. }): void;
  20293. /**
  20294. * Prepares the defines related to the light information passed in parameter
  20295. * @param scene The scene we are intending to draw
  20296. * @param mesh The mesh the effect is compiling for
  20297. * @param defines The defines to update
  20298. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20299. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20300. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20301. * @returns true if normals will be required for the rest of the effect
  20302. */
  20303. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20304. /**
  20305. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20306. * @param lightIndex defines the light index
  20307. * @param uniformsList The uniform list
  20308. * @param samplersList The sampler list
  20309. * @param projectedLightTexture defines if projected texture must be used
  20310. * @param uniformBuffersList defines an optional list of uniform buffers
  20311. */
  20312. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20313. /**
  20314. * Prepares the uniforms and samplers list to be used in the effect
  20315. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20316. * @param samplersList The sampler list
  20317. * @param defines The defines helping in the list generation
  20318. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20319. */
  20320. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20321. /**
  20322. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20323. * @param defines The defines to update while falling back
  20324. * @param fallbacks The authorized effect fallbacks
  20325. * @param maxSimultaneousLights The maximum number of lights allowed
  20326. * @param rank the current rank of the Effect
  20327. * @returns The newly affected rank
  20328. */
  20329. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20330. private static _TmpMorphInfluencers;
  20331. /**
  20332. * Prepares the list of attributes required for morph targets according to the effect defines.
  20333. * @param attribs The current list of supported attribs
  20334. * @param mesh The mesh to prepare the morph targets attributes for
  20335. * @param influencers The number of influencers
  20336. */
  20337. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20338. /**
  20339. * Prepares the list of attributes required for morph targets according to the effect defines.
  20340. * @param attribs The current list of supported attribs
  20341. * @param mesh The mesh to prepare the morph targets attributes for
  20342. * @param defines The current Defines of the effect
  20343. */
  20344. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20345. /**
  20346. * Prepares the list of attributes required for bones according to the effect defines.
  20347. * @param attribs The current list of supported attribs
  20348. * @param mesh The mesh to prepare the bones attributes for
  20349. * @param defines The current Defines of the effect
  20350. * @param fallbacks The current efffect fallback strategy
  20351. */
  20352. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20353. /**
  20354. * Check and prepare the list of attributes required for instances according to the effect defines.
  20355. * @param attribs The current list of supported attribs
  20356. * @param defines The current MaterialDefines of the effect
  20357. */
  20358. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20359. /**
  20360. * Add the list of attributes required for instances to the attribs array.
  20361. * @param attribs The current list of supported attribs
  20362. */
  20363. static PushAttributesForInstances(attribs: string[]): void;
  20364. /**
  20365. * Binds the light information to the effect.
  20366. * @param light The light containing the generator
  20367. * @param effect The effect we are binding the data to
  20368. * @param lightIndex The light index in the effect used to render
  20369. */
  20370. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20371. /**
  20372. * Binds the lights information from the scene to the effect for the given mesh.
  20373. * @param light Light to bind
  20374. * @param lightIndex Light index
  20375. * @param scene The scene where the light belongs to
  20376. * @param effect The effect we are binding the data to
  20377. * @param useSpecular Defines if specular is supported
  20378. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20379. */
  20380. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20381. /**
  20382. * Binds the lights information from the scene to the effect for the given mesh.
  20383. * @param scene The scene the lights belongs to
  20384. * @param mesh The mesh we are binding the information to render
  20385. * @param effect The effect we are binding the data to
  20386. * @param defines The generated defines for the effect
  20387. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20388. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20389. */
  20390. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20391. private static _tempFogColor;
  20392. /**
  20393. * Binds the fog information from the scene to the effect for the given mesh.
  20394. * @param scene The scene the lights belongs to
  20395. * @param mesh The mesh we are binding the information to render
  20396. * @param effect The effect we are binding the data to
  20397. * @param linearSpace Defines if the fog effect is applied in linear space
  20398. */
  20399. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20400. /**
  20401. * Binds the bones information from the mesh to the effect.
  20402. * @param mesh The mesh we are binding the information to render
  20403. * @param effect The effect we are binding the data to
  20404. */
  20405. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20406. /**
  20407. * Binds the morph targets information from the mesh to the effect.
  20408. * @param abstractMesh The mesh we are binding the information to render
  20409. * @param effect The effect we are binding the data to
  20410. */
  20411. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20412. /**
  20413. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20414. * @param defines The generated defines used in the effect
  20415. * @param effect The effect we are binding the data to
  20416. * @param scene The scene we are willing to render with logarithmic scale for
  20417. */
  20418. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20419. /**
  20420. * Binds the clip plane information from the scene to the effect.
  20421. * @param scene The scene the clip plane information are extracted from
  20422. * @param effect The effect we are binding the data to
  20423. */
  20424. static BindClipPlane(effect: Effect, scene: Scene): void;
  20425. }
  20426. }
  20427. declare module BABYLON {
  20428. /**
  20429. * Block used to expose an input value
  20430. */
  20431. export class InputBlock extends NodeMaterialBlock {
  20432. private _mode;
  20433. private _associatedVariableName;
  20434. private _storedValue;
  20435. private _valueCallback;
  20436. private _type;
  20437. private _animationType;
  20438. /** Gets or set a value used to limit the range of float values */
  20439. min: number;
  20440. /** Gets or set a value used to limit the range of float values */
  20441. max: number;
  20442. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20443. isBoolean: boolean;
  20444. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20445. matrixMode: number;
  20446. /** @hidden */
  20447. _systemValue: Nullable<NodeMaterialSystemValues>;
  20448. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20449. visibleInInspector: boolean;
  20450. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20451. isConstant: boolean;
  20452. /** Gets or sets the group to use to display this block in the Inspector */
  20453. groupInInspector: string;
  20454. /** Gets an observable raised when the value is changed */
  20455. onValueChangedObservable: Observable<InputBlock>;
  20456. /**
  20457. * Gets or sets the connection point type (default is float)
  20458. */
  20459. get type(): NodeMaterialBlockConnectionPointTypes;
  20460. /**
  20461. * Creates a new InputBlock
  20462. * @param name defines the block name
  20463. * @param target defines the target of that block (Vertex by default)
  20464. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20465. */
  20466. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20467. /**
  20468. * Validates if a name is a reserve word.
  20469. * @param newName the new name to be given to the node.
  20470. * @returns false if the name is a reserve word, else true.
  20471. */
  20472. validateBlockName(newName: string): boolean;
  20473. /**
  20474. * Gets the output component
  20475. */
  20476. get output(): NodeMaterialConnectionPoint;
  20477. /**
  20478. * Set the source of this connection point to a vertex attribute
  20479. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20480. * @returns the current connection point
  20481. */
  20482. setAsAttribute(attributeName?: string): InputBlock;
  20483. /**
  20484. * Set the source of this connection point to a system value
  20485. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20486. * @returns the current connection point
  20487. */
  20488. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20489. /**
  20490. * Gets or sets the value of that point.
  20491. * Please note that this value will be ignored if valueCallback is defined
  20492. */
  20493. get value(): any;
  20494. set value(value: any);
  20495. /**
  20496. * Gets or sets a callback used to get the value of that point.
  20497. * Please note that setting this value will force the connection point to ignore the value property
  20498. */
  20499. get valueCallback(): () => any;
  20500. set valueCallback(value: () => any);
  20501. /**
  20502. * Gets or sets the associated variable name in the shader
  20503. */
  20504. get associatedVariableName(): string;
  20505. set associatedVariableName(value: string);
  20506. /** Gets or sets the type of animation applied to the input */
  20507. get animationType(): AnimatedInputBlockTypes;
  20508. set animationType(value: AnimatedInputBlockTypes);
  20509. /**
  20510. * Gets a boolean indicating that this connection point not defined yet
  20511. */
  20512. get isUndefined(): boolean;
  20513. /**
  20514. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20515. * In this case the connection point name must be the name of the uniform to use.
  20516. * Can only be set on inputs
  20517. */
  20518. get isUniform(): boolean;
  20519. set isUniform(value: boolean);
  20520. /**
  20521. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20522. * In this case the connection point name must be the name of the attribute to use
  20523. * Can only be set on inputs
  20524. */
  20525. get isAttribute(): boolean;
  20526. set isAttribute(value: boolean);
  20527. /**
  20528. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20529. * Can only be set on exit points
  20530. */
  20531. get isVarying(): boolean;
  20532. set isVarying(value: boolean);
  20533. /**
  20534. * Gets a boolean indicating that the current connection point is a system value
  20535. */
  20536. get isSystemValue(): boolean;
  20537. /**
  20538. * Gets or sets the current well known value or null if not defined as a system value
  20539. */
  20540. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20541. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20542. /**
  20543. * Gets the current class name
  20544. * @returns the class name
  20545. */
  20546. getClassName(): string;
  20547. /**
  20548. * Animate the input if animationType !== None
  20549. * @param scene defines the rendering scene
  20550. */
  20551. animate(scene: Scene): void;
  20552. private _emitDefine;
  20553. initialize(state: NodeMaterialBuildState): void;
  20554. /**
  20555. * Set the input block to its default value (based on its type)
  20556. */
  20557. setDefaultValue(): void;
  20558. private _emitConstant;
  20559. /** @hidden */
  20560. get _noContextSwitch(): boolean;
  20561. private _emit;
  20562. /** @hidden */
  20563. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20564. /** @hidden */
  20565. _transmit(effect: Effect, scene: Scene): void;
  20566. protected _buildBlock(state: NodeMaterialBuildState): void;
  20567. protected _dumpPropertiesCode(): string;
  20568. dispose(): void;
  20569. serialize(): any;
  20570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20571. }
  20572. }
  20573. declare module BABYLON {
  20574. /**
  20575. * Enum used to define the compatibility state between two connection points
  20576. */
  20577. export enum NodeMaterialConnectionPointCompatibilityStates {
  20578. /** Points are compatibles */
  20579. Compatible = 0,
  20580. /** Points are incompatible because of their types */
  20581. TypeIncompatible = 1,
  20582. /** Points are incompatible because of their targets (vertex vs fragment) */
  20583. TargetIncompatible = 2
  20584. }
  20585. /**
  20586. * Defines the direction of a connection point
  20587. */
  20588. export enum NodeMaterialConnectionPointDirection {
  20589. /** Input */
  20590. Input = 0,
  20591. /** Output */
  20592. Output = 1
  20593. }
  20594. /**
  20595. * Defines a connection point for a block
  20596. */
  20597. export class NodeMaterialConnectionPoint {
  20598. /** @hidden */
  20599. _ownerBlock: NodeMaterialBlock;
  20600. /** @hidden */
  20601. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20602. private _endpoints;
  20603. private _associatedVariableName;
  20604. private _direction;
  20605. /** @hidden */
  20606. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20607. /** @hidden */
  20608. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20609. private _type;
  20610. /** @hidden */
  20611. _enforceAssociatedVariableName: boolean;
  20612. /** Gets the direction of the point */
  20613. get direction(): NodeMaterialConnectionPointDirection;
  20614. /** Indicates that this connection point needs dual validation before being connected to another point */
  20615. needDualDirectionValidation: boolean;
  20616. /**
  20617. * Gets or sets the additional types supported by this connection point
  20618. */
  20619. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20620. /**
  20621. * Gets or sets the additional types excluded by this connection point
  20622. */
  20623. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20624. /**
  20625. * Observable triggered when this point is connected
  20626. */
  20627. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20628. /**
  20629. * Gets or sets the associated variable name in the shader
  20630. */
  20631. get associatedVariableName(): string;
  20632. set associatedVariableName(value: string);
  20633. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20634. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20635. /**
  20636. * Gets or sets the connection point type (default is float)
  20637. */
  20638. get type(): NodeMaterialBlockConnectionPointTypes;
  20639. set type(value: NodeMaterialBlockConnectionPointTypes);
  20640. /**
  20641. * Gets or sets the connection point name
  20642. */
  20643. name: string;
  20644. /**
  20645. * Gets or sets the connection point name
  20646. */
  20647. displayName: string;
  20648. /**
  20649. * Gets or sets a boolean indicating that this connection point can be omitted
  20650. */
  20651. isOptional: boolean;
  20652. /**
  20653. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20654. */
  20655. isExposedOnFrame: boolean;
  20656. /**
  20657. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20658. */
  20659. define: string;
  20660. /** @hidden */
  20661. _prioritizeVertex: boolean;
  20662. private _target;
  20663. /** Gets or sets the target of that connection point */
  20664. get target(): NodeMaterialBlockTargets;
  20665. set target(value: NodeMaterialBlockTargets);
  20666. /**
  20667. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20668. */
  20669. get isConnected(): boolean;
  20670. /**
  20671. * Gets a boolean indicating that the current point is connected to an input block
  20672. */
  20673. get isConnectedToInputBlock(): boolean;
  20674. /**
  20675. * Gets a the connected input block (if any)
  20676. */
  20677. get connectInputBlock(): Nullable<InputBlock>;
  20678. /** Get the other side of the connection (if any) */
  20679. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20680. /** Get the block that owns this connection point */
  20681. get ownerBlock(): NodeMaterialBlock;
  20682. /** Get the block connected on the other side of this connection (if any) */
  20683. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20684. /** Get the block connected on the endpoints of this connection (if any) */
  20685. get connectedBlocks(): Array<NodeMaterialBlock>;
  20686. /** Gets the list of connected endpoints */
  20687. get endpoints(): NodeMaterialConnectionPoint[];
  20688. /** Gets a boolean indicating if that output point is connected to at least one input */
  20689. get hasEndpoints(): boolean;
  20690. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20691. get isConnectedInVertexShader(): boolean;
  20692. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20693. get isConnectedInFragmentShader(): boolean;
  20694. /**
  20695. * Creates a block suitable to be used as an input for this input point.
  20696. * If null is returned, a block based on the point type will be created.
  20697. * @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
  20698. */
  20699. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20700. /**
  20701. * Creates a new connection point
  20702. * @param name defines the connection point name
  20703. * @param ownerBlock defines the block hosting this connection point
  20704. * @param direction defines the direction of the connection point
  20705. */
  20706. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20707. /**
  20708. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20709. * @returns the class name
  20710. */
  20711. getClassName(): string;
  20712. /**
  20713. * Gets a boolean indicating if the current point can be connected to another point
  20714. * @param connectionPoint defines the other connection point
  20715. * @returns a boolean
  20716. */
  20717. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20718. /**
  20719. * Gets a number indicating if the current point can be connected to another point
  20720. * @param connectionPoint defines the other connection point
  20721. * @returns a number defining the compatibility state
  20722. */
  20723. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20724. /**
  20725. * Connect this point to another connection point
  20726. * @param connectionPoint defines the other connection point
  20727. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20728. * @returns the current connection point
  20729. */
  20730. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20731. /**
  20732. * Disconnect this point from one of his endpoint
  20733. * @param endpoint defines the other connection point
  20734. * @returns the current connection point
  20735. */
  20736. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20737. /**
  20738. * Serializes this point in a JSON representation
  20739. * @param isInput defines if the connection point is an input (default is true)
  20740. * @returns the serialized point object
  20741. */
  20742. serialize(isInput?: boolean): any;
  20743. /**
  20744. * Release resources
  20745. */
  20746. dispose(): void;
  20747. }
  20748. }
  20749. declare module BABYLON {
  20750. /**
  20751. * Enum used to define the material modes
  20752. */
  20753. export enum NodeMaterialModes {
  20754. /** Regular material */
  20755. Material = 0,
  20756. /** For post process */
  20757. PostProcess = 1,
  20758. /** For particle system */
  20759. Particle = 2
  20760. }
  20761. }
  20762. declare module BABYLON {
  20763. /**
  20764. * Block used to read a texture from a sampler
  20765. */
  20766. export class TextureBlock extends NodeMaterialBlock {
  20767. private _defineName;
  20768. private _linearDefineName;
  20769. private _gammaDefineName;
  20770. private _tempTextureRead;
  20771. private _samplerName;
  20772. private _transformedUVName;
  20773. private _textureTransformName;
  20774. private _textureInfoName;
  20775. private _mainUVName;
  20776. private _mainUVDefineName;
  20777. private _fragmentOnly;
  20778. /**
  20779. * Gets or sets the texture associated with the node
  20780. */
  20781. texture: Nullable<Texture>;
  20782. /**
  20783. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20784. */
  20785. convertToGammaSpace: boolean;
  20786. /**
  20787. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20788. */
  20789. convertToLinearSpace: boolean;
  20790. /**
  20791. * Create a new TextureBlock
  20792. * @param name defines the block name
  20793. */
  20794. constructor(name: string, fragmentOnly?: boolean);
  20795. /**
  20796. * Gets the current class name
  20797. * @returns the class name
  20798. */
  20799. getClassName(): string;
  20800. /**
  20801. * Gets the uv input component
  20802. */
  20803. get uv(): NodeMaterialConnectionPoint;
  20804. /**
  20805. * Gets the rgba output component
  20806. */
  20807. get rgba(): NodeMaterialConnectionPoint;
  20808. /**
  20809. * Gets the rgb output component
  20810. */
  20811. get rgb(): NodeMaterialConnectionPoint;
  20812. /**
  20813. * Gets the r output component
  20814. */
  20815. get r(): NodeMaterialConnectionPoint;
  20816. /**
  20817. * Gets the g output component
  20818. */
  20819. get g(): NodeMaterialConnectionPoint;
  20820. /**
  20821. * Gets the b output component
  20822. */
  20823. get b(): NodeMaterialConnectionPoint;
  20824. /**
  20825. * Gets the a output component
  20826. */
  20827. get a(): NodeMaterialConnectionPoint;
  20828. get target(): NodeMaterialBlockTargets;
  20829. autoConfigure(material: NodeMaterial): void;
  20830. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20832. isReady(): boolean;
  20833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20834. private get _isMixed();
  20835. private _injectVertexCode;
  20836. private _writeTextureRead;
  20837. private _writeOutput;
  20838. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20839. protected _dumpPropertiesCode(): string;
  20840. serialize(): any;
  20841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20842. }
  20843. }
  20844. declare module BABYLON {
  20845. /** @hidden */
  20846. export var reflectionFunction: {
  20847. name: string;
  20848. shader: string;
  20849. };
  20850. }
  20851. declare module BABYLON {
  20852. /**
  20853. * Base block used to read a reflection texture from a sampler
  20854. */
  20855. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20856. /** @hidden */
  20857. _define3DName: string;
  20858. /** @hidden */
  20859. _defineCubicName: string;
  20860. /** @hidden */
  20861. _defineExplicitName: string;
  20862. /** @hidden */
  20863. _defineProjectionName: string;
  20864. /** @hidden */
  20865. _defineLocalCubicName: string;
  20866. /** @hidden */
  20867. _defineSphericalName: string;
  20868. /** @hidden */
  20869. _definePlanarName: string;
  20870. /** @hidden */
  20871. _defineEquirectangularName: string;
  20872. /** @hidden */
  20873. _defineMirroredEquirectangularFixedName: string;
  20874. /** @hidden */
  20875. _defineEquirectangularFixedName: string;
  20876. /** @hidden */
  20877. _defineSkyboxName: string;
  20878. /** @hidden */
  20879. _defineOppositeZ: string;
  20880. /** @hidden */
  20881. _cubeSamplerName: string;
  20882. /** @hidden */
  20883. _2DSamplerName: string;
  20884. protected _positionUVWName: string;
  20885. protected _directionWName: string;
  20886. protected _reflectionVectorName: string;
  20887. /** @hidden */
  20888. _reflectionCoordsName: string;
  20889. /** @hidden */
  20890. _reflectionMatrixName: string;
  20891. protected _reflectionColorName: string;
  20892. /**
  20893. * Gets or sets the texture associated with the node
  20894. */
  20895. texture: Nullable<BaseTexture>;
  20896. /**
  20897. * Create a new ReflectionTextureBaseBlock
  20898. * @param name defines the block name
  20899. */
  20900. constructor(name: string);
  20901. /**
  20902. * Gets the current class name
  20903. * @returns the class name
  20904. */
  20905. getClassName(): string;
  20906. /**
  20907. * Gets the world position input component
  20908. */
  20909. abstract get position(): NodeMaterialConnectionPoint;
  20910. /**
  20911. * Gets the world position input component
  20912. */
  20913. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20914. /**
  20915. * Gets the world normal input component
  20916. */
  20917. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20918. /**
  20919. * Gets the world input component
  20920. */
  20921. abstract get world(): NodeMaterialConnectionPoint;
  20922. /**
  20923. * Gets the camera (or eye) position component
  20924. */
  20925. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20926. /**
  20927. * Gets the view input component
  20928. */
  20929. abstract get view(): NodeMaterialConnectionPoint;
  20930. protected _getTexture(): Nullable<BaseTexture>;
  20931. autoConfigure(material: NodeMaterial): void;
  20932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20933. isReady(): boolean;
  20934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20935. /**
  20936. * Gets the code to inject in the vertex shader
  20937. * @param state current state of the node material building
  20938. * @returns the shader code
  20939. */
  20940. handleVertexSide(state: NodeMaterialBuildState): string;
  20941. /**
  20942. * Handles the inits for the fragment code path
  20943. * @param state node material build state
  20944. */
  20945. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20946. /**
  20947. * Generates the reflection coords code for the fragment code path
  20948. * @param worldNormalVarName name of the world normal variable
  20949. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20950. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20951. * @returns the shader code
  20952. */
  20953. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20954. /**
  20955. * Generates the reflection color code for the fragment code path
  20956. * @param lodVarName name of the lod variable
  20957. * @param swizzleLookupTexture swizzle to use for the final color variable
  20958. * @returns the shader code
  20959. */
  20960. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20961. /**
  20962. * Generates the code corresponding to the connected output points
  20963. * @param state node material build state
  20964. * @param varName name of the variable to output
  20965. * @returns the shader code
  20966. */
  20967. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20968. protected _buildBlock(state: NodeMaterialBuildState): this;
  20969. protected _dumpPropertiesCode(): string;
  20970. serialize(): any;
  20971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20972. }
  20973. }
  20974. declare module BABYLON {
  20975. /**
  20976. * Defines a connection point to be used for points with a custom object type
  20977. */
  20978. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20979. private _blockType;
  20980. private _blockName;
  20981. private _nameForCheking?;
  20982. /**
  20983. * Creates a new connection point
  20984. * @param name defines the connection point name
  20985. * @param ownerBlock defines the block hosting this connection point
  20986. * @param direction defines the direction of the connection point
  20987. */
  20988. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20989. /**
  20990. * Gets a number indicating if the current point can be connected to another point
  20991. * @param connectionPoint defines the other connection point
  20992. * @returns a number defining the compatibility state
  20993. */
  20994. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20995. /**
  20996. * Creates a block suitable to be used as an input for this input point.
  20997. * If null is returned, a block based on the point type will be created.
  20998. * @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
  20999. */
  21000. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21001. }
  21002. }
  21003. declare module BABYLON {
  21004. /**
  21005. * Enum defining the type of properties that can be edited in the property pages in the NME
  21006. */
  21007. export enum PropertyTypeForEdition {
  21008. /** property is a boolean */
  21009. Boolean = 0,
  21010. /** property is a float */
  21011. Float = 1,
  21012. /** property is a Vector2 */
  21013. Vector2 = 2,
  21014. /** property is a list of values */
  21015. List = 3
  21016. }
  21017. /**
  21018. * Interface that defines an option in a variable of type list
  21019. */
  21020. export interface IEditablePropertyListOption {
  21021. /** label of the option */
  21022. "label": string;
  21023. /** value of the option */
  21024. "value": number;
  21025. }
  21026. /**
  21027. * Interface that defines the options available for an editable property
  21028. */
  21029. export interface IEditablePropertyOption {
  21030. /** min value */
  21031. "min"?: number;
  21032. /** max value */
  21033. "max"?: number;
  21034. /** notifiers: indicates which actions to take when the property is changed */
  21035. "notifiers"?: {
  21036. /** the material should be rebuilt */
  21037. "rebuild"?: boolean;
  21038. /** the preview should be updated */
  21039. "update"?: boolean;
  21040. };
  21041. /** list of the options for a variable of type list */
  21042. "options"?: IEditablePropertyListOption[];
  21043. }
  21044. /**
  21045. * Interface that describes an editable property
  21046. */
  21047. export interface IPropertyDescriptionForEdition {
  21048. /** name of the property */
  21049. "propertyName": string;
  21050. /** display name of the property */
  21051. "displayName": string;
  21052. /** type of the property */
  21053. "type": PropertyTypeForEdition;
  21054. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21055. "groupName": string;
  21056. /** options for the property */
  21057. "options": IEditablePropertyOption;
  21058. }
  21059. /**
  21060. * Decorator that flags a property in a node material block as being editable
  21061. */
  21062. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21063. }
  21064. declare module BABYLON {
  21065. /**
  21066. * Block used to implement the refraction part of the sub surface module of the PBR material
  21067. */
  21068. export class RefractionBlock extends NodeMaterialBlock {
  21069. /** @hidden */
  21070. _define3DName: string;
  21071. /** @hidden */
  21072. _refractionMatrixName: string;
  21073. /** @hidden */
  21074. _defineLODRefractionAlpha: string;
  21075. /** @hidden */
  21076. _defineLinearSpecularRefraction: string;
  21077. /** @hidden */
  21078. _defineOppositeZ: string;
  21079. /** @hidden */
  21080. _cubeSamplerName: string;
  21081. /** @hidden */
  21082. _2DSamplerName: string;
  21083. /** @hidden */
  21084. _vRefractionMicrosurfaceInfosName: string;
  21085. /** @hidden */
  21086. _vRefractionInfosName: string;
  21087. private _scene;
  21088. /**
  21089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21090. * Materials half opaque for instance using refraction could benefit from this control.
  21091. */
  21092. linkRefractionWithTransparency: boolean;
  21093. /**
  21094. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21095. */
  21096. invertRefractionY: boolean;
  21097. /**
  21098. * Gets or sets the texture associated with the node
  21099. */
  21100. texture: Nullable<BaseTexture>;
  21101. /**
  21102. * Create a new RefractionBlock
  21103. * @param name defines the block name
  21104. */
  21105. constructor(name: string);
  21106. /**
  21107. * Gets the current class name
  21108. * @returns the class name
  21109. */
  21110. getClassName(): string;
  21111. /**
  21112. * Gets the intensity input component
  21113. */
  21114. get intensity(): NodeMaterialConnectionPoint;
  21115. /**
  21116. * Gets the index of refraction input component
  21117. */
  21118. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21119. /**
  21120. * Gets the tint at distance input component
  21121. */
  21122. get tintAtDistance(): NodeMaterialConnectionPoint;
  21123. /**
  21124. * Gets the view input component
  21125. */
  21126. get view(): NodeMaterialConnectionPoint;
  21127. /**
  21128. * Gets the refraction object output component
  21129. */
  21130. get refraction(): NodeMaterialConnectionPoint;
  21131. /**
  21132. * Returns true if the block has a texture
  21133. */
  21134. get hasTexture(): boolean;
  21135. protected _getTexture(): Nullable<BaseTexture>;
  21136. autoConfigure(material: NodeMaterial): void;
  21137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21138. isReady(): boolean;
  21139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21140. /**
  21141. * Gets the main code of the block (fragment side)
  21142. * @param state current state of the node material building
  21143. * @returns the shader code
  21144. */
  21145. getCode(state: NodeMaterialBuildState): string;
  21146. protected _buildBlock(state: NodeMaterialBuildState): this;
  21147. protected _dumpPropertiesCode(): string;
  21148. serialize(): any;
  21149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21150. }
  21151. }
  21152. declare module BABYLON {
  21153. /**
  21154. * Base block used as input for post process
  21155. */
  21156. export class CurrentScreenBlock extends NodeMaterialBlock {
  21157. private _samplerName;
  21158. private _linearDefineName;
  21159. private _gammaDefineName;
  21160. private _mainUVName;
  21161. private _tempTextureRead;
  21162. /**
  21163. * Gets or sets the texture associated with the node
  21164. */
  21165. texture: Nullable<BaseTexture>;
  21166. /**
  21167. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21168. */
  21169. convertToGammaSpace: boolean;
  21170. /**
  21171. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21172. */
  21173. convertToLinearSpace: boolean;
  21174. /**
  21175. * Create a new CurrentScreenBlock
  21176. * @param name defines the block name
  21177. */
  21178. constructor(name: string);
  21179. /**
  21180. * Gets the current class name
  21181. * @returns the class name
  21182. */
  21183. getClassName(): string;
  21184. /**
  21185. * Gets the uv input component
  21186. */
  21187. get uv(): NodeMaterialConnectionPoint;
  21188. /**
  21189. * Gets the rgba output component
  21190. */
  21191. get rgba(): NodeMaterialConnectionPoint;
  21192. /**
  21193. * Gets the rgb output component
  21194. */
  21195. get rgb(): NodeMaterialConnectionPoint;
  21196. /**
  21197. * Gets the r output component
  21198. */
  21199. get r(): NodeMaterialConnectionPoint;
  21200. /**
  21201. * Gets the g output component
  21202. */
  21203. get g(): NodeMaterialConnectionPoint;
  21204. /**
  21205. * Gets the b output component
  21206. */
  21207. get b(): NodeMaterialConnectionPoint;
  21208. /**
  21209. * Gets the a output component
  21210. */
  21211. get a(): NodeMaterialConnectionPoint;
  21212. /**
  21213. * Initialize the block and prepare the context for build
  21214. * @param state defines the state that will be used for the build
  21215. */
  21216. initialize(state: NodeMaterialBuildState): void;
  21217. get target(): NodeMaterialBlockTargets;
  21218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21219. isReady(): boolean;
  21220. private _injectVertexCode;
  21221. private _writeTextureRead;
  21222. private _writeOutput;
  21223. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21224. serialize(): any;
  21225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21226. }
  21227. }
  21228. declare module BABYLON {
  21229. /**
  21230. * Base block used for the particle texture
  21231. */
  21232. export class ParticleTextureBlock extends NodeMaterialBlock {
  21233. private _samplerName;
  21234. private _linearDefineName;
  21235. private _gammaDefineName;
  21236. private _tempTextureRead;
  21237. /**
  21238. * Gets or sets the texture associated with the node
  21239. */
  21240. texture: Nullable<BaseTexture>;
  21241. /**
  21242. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21243. */
  21244. convertToGammaSpace: boolean;
  21245. /**
  21246. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21247. */
  21248. convertToLinearSpace: boolean;
  21249. /**
  21250. * Create a new ParticleTextureBlock
  21251. * @param name defines the block name
  21252. */
  21253. constructor(name: string);
  21254. /**
  21255. * Gets the current class name
  21256. * @returns the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Gets the uv input component
  21261. */
  21262. get uv(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the rgba output component
  21265. */
  21266. get rgba(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the rgb output component
  21269. */
  21270. get rgb(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the r output component
  21273. */
  21274. get r(): NodeMaterialConnectionPoint;
  21275. /**
  21276. * Gets the g output component
  21277. */
  21278. get g(): NodeMaterialConnectionPoint;
  21279. /**
  21280. * Gets the b output component
  21281. */
  21282. get b(): NodeMaterialConnectionPoint;
  21283. /**
  21284. * Gets the a output component
  21285. */
  21286. get a(): NodeMaterialConnectionPoint;
  21287. /**
  21288. * Initialize the block and prepare the context for build
  21289. * @param state defines the state that will be used for the build
  21290. */
  21291. initialize(state: NodeMaterialBuildState): void;
  21292. autoConfigure(material: NodeMaterial): void;
  21293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21294. isReady(): boolean;
  21295. private _writeOutput;
  21296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21297. serialize(): any;
  21298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21299. }
  21300. }
  21301. declare module BABYLON {
  21302. /**
  21303. * Class used to store shared data between 2 NodeMaterialBuildState
  21304. */
  21305. export class NodeMaterialBuildStateSharedData {
  21306. /**
  21307. * Gets the list of emitted varyings
  21308. */
  21309. temps: string[];
  21310. /**
  21311. * Gets the list of emitted varyings
  21312. */
  21313. varyings: string[];
  21314. /**
  21315. * Gets the varying declaration string
  21316. */
  21317. varyingDeclaration: string;
  21318. /**
  21319. * Input blocks
  21320. */
  21321. inputBlocks: InputBlock[];
  21322. /**
  21323. * Input blocks
  21324. */
  21325. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21326. /**
  21327. * Bindable blocks (Blocks that need to set data to the effect)
  21328. */
  21329. bindableBlocks: NodeMaterialBlock[];
  21330. /**
  21331. * List of blocks that can provide a compilation fallback
  21332. */
  21333. blocksWithFallbacks: NodeMaterialBlock[];
  21334. /**
  21335. * List of blocks that can provide a define update
  21336. */
  21337. blocksWithDefines: NodeMaterialBlock[];
  21338. /**
  21339. * List of blocks that can provide a repeatable content
  21340. */
  21341. repeatableContentBlocks: NodeMaterialBlock[];
  21342. /**
  21343. * List of blocks that can provide a dynamic list of uniforms
  21344. */
  21345. dynamicUniformBlocks: NodeMaterialBlock[];
  21346. /**
  21347. * List of blocks that can block the isReady function for the material
  21348. */
  21349. blockingBlocks: NodeMaterialBlock[];
  21350. /**
  21351. * Gets the list of animated inputs
  21352. */
  21353. animatedInputs: InputBlock[];
  21354. /**
  21355. * Build Id used to avoid multiple recompilations
  21356. */
  21357. buildId: number;
  21358. /** List of emitted variables */
  21359. variableNames: {
  21360. [key: string]: number;
  21361. };
  21362. /** List of emitted defines */
  21363. defineNames: {
  21364. [key: string]: number;
  21365. };
  21366. /** Should emit comments? */
  21367. emitComments: boolean;
  21368. /** Emit build activity */
  21369. verbose: boolean;
  21370. /** Gets or sets the hosting scene */
  21371. scene: Scene;
  21372. /**
  21373. * Gets the compilation hints emitted at compilation time
  21374. */
  21375. hints: {
  21376. needWorldViewMatrix: boolean;
  21377. needWorldViewProjectionMatrix: boolean;
  21378. needAlphaBlending: boolean;
  21379. needAlphaTesting: boolean;
  21380. };
  21381. /**
  21382. * List of compilation checks
  21383. */
  21384. checks: {
  21385. emitVertex: boolean;
  21386. emitFragment: boolean;
  21387. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21388. };
  21389. /**
  21390. * Is vertex program allowed to be empty?
  21391. */
  21392. allowEmptyVertexProgram: boolean;
  21393. /** Creates a new shared data */
  21394. constructor();
  21395. /**
  21396. * Emits console errors and exceptions if there is a failing check
  21397. */
  21398. emitErrors(): void;
  21399. }
  21400. }
  21401. declare module BABYLON {
  21402. /**
  21403. * Class used to store node based material build state
  21404. */
  21405. export class NodeMaterialBuildState {
  21406. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21407. supportUniformBuffers: boolean;
  21408. /**
  21409. * Gets the list of emitted attributes
  21410. */
  21411. attributes: string[];
  21412. /**
  21413. * Gets the list of emitted uniforms
  21414. */
  21415. uniforms: string[];
  21416. /**
  21417. * Gets the list of emitted constants
  21418. */
  21419. constants: string[];
  21420. /**
  21421. * Gets the list of emitted samplers
  21422. */
  21423. samplers: string[];
  21424. /**
  21425. * Gets the list of emitted functions
  21426. */
  21427. functions: {
  21428. [key: string]: string;
  21429. };
  21430. /**
  21431. * Gets the list of emitted extensions
  21432. */
  21433. extensions: {
  21434. [key: string]: string;
  21435. };
  21436. /**
  21437. * Gets the target of the compilation state
  21438. */
  21439. target: NodeMaterialBlockTargets;
  21440. /**
  21441. * Gets the list of emitted counters
  21442. */
  21443. counters: {
  21444. [key: string]: number;
  21445. };
  21446. /**
  21447. * Shared data between multiple NodeMaterialBuildState instances
  21448. */
  21449. sharedData: NodeMaterialBuildStateSharedData;
  21450. /** @hidden */
  21451. _vertexState: NodeMaterialBuildState;
  21452. /** @hidden */
  21453. _attributeDeclaration: string;
  21454. /** @hidden */
  21455. _uniformDeclaration: string;
  21456. /** @hidden */
  21457. _constantDeclaration: string;
  21458. /** @hidden */
  21459. _samplerDeclaration: string;
  21460. /** @hidden */
  21461. _varyingTransfer: string;
  21462. /** @hidden */
  21463. _injectAtEnd: string;
  21464. private _repeatableContentAnchorIndex;
  21465. /** @hidden */
  21466. _builtCompilationString: string;
  21467. /**
  21468. * Gets the emitted compilation strings
  21469. */
  21470. compilationString: string;
  21471. /**
  21472. * Finalize the compilation strings
  21473. * @param state defines the current compilation state
  21474. */
  21475. finalize(state: NodeMaterialBuildState): void;
  21476. /** @hidden */
  21477. get _repeatableContentAnchor(): string;
  21478. /** @hidden */
  21479. _getFreeVariableName(prefix: string): string;
  21480. /** @hidden */
  21481. _getFreeDefineName(prefix: string): string;
  21482. /** @hidden */
  21483. _excludeVariableName(name: string): void;
  21484. /** @hidden */
  21485. _emit2DSampler(name: string): void;
  21486. /** @hidden */
  21487. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21488. /** @hidden */
  21489. _emitExtension(name: string, extension: string, define?: string): void;
  21490. /** @hidden */
  21491. _emitFunction(name: string, code: string, comments: string): void;
  21492. /** @hidden */
  21493. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21494. replaceStrings?: {
  21495. search: RegExp;
  21496. replace: string;
  21497. }[];
  21498. repeatKey?: string;
  21499. }): string;
  21500. /** @hidden */
  21501. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21502. repeatKey?: string;
  21503. removeAttributes?: boolean;
  21504. removeUniforms?: boolean;
  21505. removeVaryings?: boolean;
  21506. removeIfDef?: boolean;
  21507. replaceStrings?: {
  21508. search: RegExp;
  21509. replace: string;
  21510. }[];
  21511. }, storeKey?: string): void;
  21512. /** @hidden */
  21513. _registerTempVariable(name: string): boolean;
  21514. /** @hidden */
  21515. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21516. /** @hidden */
  21517. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21518. /** @hidden */
  21519. _emitFloat(value: number): string;
  21520. }
  21521. }
  21522. declare module BABYLON {
  21523. /**
  21524. * Helper class used to generate session unique ID
  21525. */
  21526. export class UniqueIdGenerator {
  21527. private static _UniqueIdCounter;
  21528. /**
  21529. * Gets an unique (relatively to the current scene) Id
  21530. */
  21531. static get UniqueId(): number;
  21532. }
  21533. }
  21534. declare module BABYLON {
  21535. /**
  21536. * Defines a block that can be used inside a node based material
  21537. */
  21538. export class NodeMaterialBlock {
  21539. private _buildId;
  21540. private _buildTarget;
  21541. private _target;
  21542. private _isFinalMerger;
  21543. private _isInput;
  21544. private _name;
  21545. protected _isUnique: boolean;
  21546. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21547. inputsAreExclusive: boolean;
  21548. /** @hidden */
  21549. _codeVariableName: string;
  21550. /** @hidden */
  21551. _inputs: NodeMaterialConnectionPoint[];
  21552. /** @hidden */
  21553. _outputs: NodeMaterialConnectionPoint[];
  21554. /** @hidden */
  21555. _preparationId: number;
  21556. /**
  21557. * Gets the name of the block
  21558. */
  21559. get name(): string;
  21560. /**
  21561. * Sets the name of the block. Will check if the name is valid.
  21562. */
  21563. set name(newName: string);
  21564. /**
  21565. * Gets or sets the unique id of the node
  21566. */
  21567. uniqueId: number;
  21568. /**
  21569. * Gets or sets the comments associated with this block
  21570. */
  21571. comments: string;
  21572. /**
  21573. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21574. */
  21575. get isUnique(): boolean;
  21576. /**
  21577. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21578. */
  21579. get isFinalMerger(): boolean;
  21580. /**
  21581. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21582. */
  21583. get isInput(): boolean;
  21584. /**
  21585. * Gets or sets the build Id
  21586. */
  21587. get buildId(): number;
  21588. set buildId(value: number);
  21589. /**
  21590. * Gets or sets the target of the block
  21591. */
  21592. get target(): NodeMaterialBlockTargets;
  21593. set target(value: NodeMaterialBlockTargets);
  21594. /**
  21595. * Gets the list of input points
  21596. */
  21597. get inputs(): NodeMaterialConnectionPoint[];
  21598. /** Gets the list of output points */
  21599. get outputs(): NodeMaterialConnectionPoint[];
  21600. /**
  21601. * Find an input by its name
  21602. * @param name defines the name of the input to look for
  21603. * @returns the input or null if not found
  21604. */
  21605. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21606. /**
  21607. * Find an output by its name
  21608. * @param name defines the name of the outputto look for
  21609. * @returns the output or null if not found
  21610. */
  21611. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21612. /**
  21613. * Creates a new NodeMaterialBlock
  21614. * @param name defines the block name
  21615. * @param target defines the target of that block (Vertex by default)
  21616. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21617. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21618. */
  21619. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21620. /**
  21621. * Initialize the block and prepare the context for build
  21622. * @param state defines the state that will be used for the build
  21623. */
  21624. initialize(state: NodeMaterialBuildState): void;
  21625. /**
  21626. * Bind data to effect. Will only be called for blocks with isBindable === true
  21627. * @param effect defines the effect to bind data to
  21628. * @param nodeMaterial defines the hosting NodeMaterial
  21629. * @param mesh defines the mesh that will be rendered
  21630. * @param subMesh defines the submesh that will be rendered
  21631. */
  21632. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21633. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21634. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21635. protected _writeFloat(value: number): string;
  21636. /**
  21637. * Gets the current class name e.g. "NodeMaterialBlock"
  21638. * @returns the class name
  21639. */
  21640. getClassName(): string;
  21641. /**
  21642. * Register a new input. Must be called inside a block constructor
  21643. * @param name defines the connection point name
  21644. * @param type defines the connection point type
  21645. * @param isOptional defines a boolean indicating that this input can be omitted
  21646. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21647. * @param point an already created connection point. If not provided, create a new one
  21648. * @returns the current block
  21649. */
  21650. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21651. /**
  21652. * Register a new output. Must be called inside a block constructor
  21653. * @param name defines the connection point name
  21654. * @param type defines the connection point type
  21655. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21656. * @param point an already created connection point. If not provided, create a new one
  21657. * @returns the current block
  21658. */
  21659. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21660. /**
  21661. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21662. * @param forOutput defines an optional connection point to check compatibility with
  21663. * @returns the first available input or null
  21664. */
  21665. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21666. /**
  21667. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21668. * @param forBlock defines an optional block to check compatibility with
  21669. * @returns the first available input or null
  21670. */
  21671. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21672. /**
  21673. * Gets the sibling of the given output
  21674. * @param current defines the current output
  21675. * @returns the next output in the list or null
  21676. */
  21677. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21678. /**
  21679. * Connect current block with another block
  21680. * @param other defines the block to connect with
  21681. * @param options define the various options to help pick the right connections
  21682. * @returns the current block
  21683. */
  21684. connectTo(other: NodeMaterialBlock, options?: {
  21685. input?: string;
  21686. output?: string;
  21687. outputSwizzle?: string;
  21688. }): this | undefined;
  21689. protected _buildBlock(state: NodeMaterialBuildState): void;
  21690. /**
  21691. * Add uniforms, samplers and uniform buffers at compilation time
  21692. * @param state defines the state to update
  21693. * @param nodeMaterial defines the node material requesting the update
  21694. * @param defines defines the material defines to update
  21695. * @param uniformBuffers defines the list of uniform buffer names
  21696. */
  21697. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21698. /**
  21699. * Add potential fallbacks if shader compilation fails
  21700. * @param mesh defines the mesh to be rendered
  21701. * @param fallbacks defines the current prioritized list of fallbacks
  21702. */
  21703. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21704. /**
  21705. * Initialize defines for shader compilation
  21706. * @param mesh defines the mesh to be rendered
  21707. * @param nodeMaterial defines the node material requesting the update
  21708. * @param defines defines the material defines to update
  21709. * @param useInstances specifies that instances should be used
  21710. */
  21711. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21712. /**
  21713. * Update defines for shader compilation
  21714. * @param mesh defines the mesh to be rendered
  21715. * @param nodeMaterial defines the node material requesting the update
  21716. * @param defines defines the material defines to update
  21717. * @param useInstances specifies that instances should be used
  21718. * @param subMesh defines which submesh to render
  21719. */
  21720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21721. /**
  21722. * Lets the block try to connect some inputs automatically
  21723. * @param material defines the hosting NodeMaterial
  21724. */
  21725. autoConfigure(material: NodeMaterial): void;
  21726. /**
  21727. * Function called when a block is declared as repeatable content generator
  21728. * @param vertexShaderState defines the current compilation state for the vertex shader
  21729. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21730. * @param mesh defines the mesh to be rendered
  21731. * @param defines defines the material defines to update
  21732. */
  21733. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21734. /**
  21735. * Checks if the block is ready
  21736. * @param mesh defines the mesh to be rendered
  21737. * @param nodeMaterial defines the node material requesting the update
  21738. * @param defines defines the material defines to update
  21739. * @param useInstances specifies that instances should be used
  21740. * @returns true if the block is ready
  21741. */
  21742. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21743. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21744. private _processBuild;
  21745. /**
  21746. * Validates the new name for the block node.
  21747. * @param newName the new name to be given to the node.
  21748. * @returns false if the name is a reserve word, else true.
  21749. */
  21750. validateBlockName(newName: string): boolean;
  21751. /**
  21752. * Compile the current node and generate the shader code
  21753. * @param state defines the current compilation state (uniforms, samplers, current string)
  21754. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21755. * @returns true if already built
  21756. */
  21757. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21758. protected _inputRename(name: string): string;
  21759. protected _outputRename(name: string): string;
  21760. protected _dumpPropertiesCode(): string;
  21761. /** @hidden */
  21762. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21763. /** @hidden */
  21764. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21765. /**
  21766. * Clone the current block to a new identical block
  21767. * @param scene defines the hosting scene
  21768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21769. * @returns a copy of the current block
  21770. */
  21771. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21772. /**
  21773. * Serializes this block in a JSON representation
  21774. * @returns the serialized block object
  21775. */
  21776. serialize(): any;
  21777. /** @hidden */
  21778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21779. private _deserializePortDisplayNamesAndExposedOnFrame;
  21780. /**
  21781. * Release resources
  21782. */
  21783. dispose(): void;
  21784. }
  21785. }
  21786. declare module BABYLON {
  21787. /**
  21788. * Base class of materials working in push mode in babylon JS
  21789. * @hidden
  21790. */
  21791. export class PushMaterial extends Material {
  21792. protected _activeEffect: Effect;
  21793. protected _normalMatrix: Matrix;
  21794. constructor(name: string, scene: Scene);
  21795. getEffect(): Effect;
  21796. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21797. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21798. /**
  21799. * Binds the given world matrix to the active effect
  21800. *
  21801. * @param world the matrix to bind
  21802. */
  21803. bindOnlyWorldMatrix(world: Matrix): void;
  21804. /**
  21805. * Binds the given normal matrix to the active effect
  21806. *
  21807. * @param normalMatrix the matrix to bind
  21808. */
  21809. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21810. bind(world: Matrix, mesh?: Mesh): void;
  21811. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21812. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21813. }
  21814. }
  21815. declare module BABYLON {
  21816. /**
  21817. * Root class for all node material optimizers
  21818. */
  21819. export class NodeMaterialOptimizer {
  21820. /**
  21821. * Function used to optimize a NodeMaterial graph
  21822. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21823. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21824. */
  21825. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21826. }
  21827. }
  21828. declare module BABYLON {
  21829. /**
  21830. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21831. */
  21832. export class TransformBlock extends NodeMaterialBlock {
  21833. /**
  21834. * Defines the value to use to complement W value to transform it to a Vector4
  21835. */
  21836. complementW: number;
  21837. /**
  21838. * Defines the value to use to complement z value to transform it to a Vector4
  21839. */
  21840. complementZ: number;
  21841. /**
  21842. * Creates a new TransformBlock
  21843. * @param name defines the block name
  21844. */
  21845. constructor(name: string);
  21846. /**
  21847. * Gets the current class name
  21848. * @returns the class name
  21849. */
  21850. getClassName(): string;
  21851. /**
  21852. * Gets the vector input
  21853. */
  21854. get vector(): NodeMaterialConnectionPoint;
  21855. /**
  21856. * Gets the output component
  21857. */
  21858. get output(): NodeMaterialConnectionPoint;
  21859. /**
  21860. * Gets the xyz output component
  21861. */
  21862. get xyz(): NodeMaterialConnectionPoint;
  21863. /**
  21864. * Gets the matrix transform input
  21865. */
  21866. get transform(): NodeMaterialConnectionPoint;
  21867. protected _buildBlock(state: NodeMaterialBuildState): this;
  21868. /**
  21869. * Update defines for shader compilation
  21870. * @param mesh defines the mesh to be rendered
  21871. * @param nodeMaterial defines the node material requesting the update
  21872. * @param defines defines the material defines to update
  21873. * @param useInstances specifies that instances should be used
  21874. * @param subMesh defines which submesh to render
  21875. */
  21876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21877. serialize(): any;
  21878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21879. protected _dumpPropertiesCode(): string;
  21880. }
  21881. }
  21882. declare module BABYLON {
  21883. /**
  21884. * Block used to output the vertex position
  21885. */
  21886. export class VertexOutputBlock extends NodeMaterialBlock {
  21887. /**
  21888. * Creates a new VertexOutputBlock
  21889. * @param name defines the block name
  21890. */
  21891. constructor(name: string);
  21892. /**
  21893. * Gets the current class name
  21894. * @returns the class name
  21895. */
  21896. getClassName(): string;
  21897. /**
  21898. * Gets the vector input component
  21899. */
  21900. get vector(): NodeMaterialConnectionPoint;
  21901. protected _buildBlock(state: NodeMaterialBuildState): this;
  21902. }
  21903. }
  21904. declare module BABYLON {
  21905. /**
  21906. * Block used to output the final color
  21907. */
  21908. export class FragmentOutputBlock extends NodeMaterialBlock {
  21909. /**
  21910. * Create a new FragmentOutputBlock
  21911. * @param name defines the block name
  21912. */
  21913. constructor(name: string);
  21914. /**
  21915. * Gets the current class name
  21916. * @returns the class name
  21917. */
  21918. getClassName(): string;
  21919. /**
  21920. * Gets the rgba input component
  21921. */
  21922. get rgba(): NodeMaterialConnectionPoint;
  21923. /**
  21924. * Gets the rgb input component
  21925. */
  21926. get rgb(): NodeMaterialConnectionPoint;
  21927. /**
  21928. * Gets the a input component
  21929. */
  21930. get a(): NodeMaterialConnectionPoint;
  21931. protected _buildBlock(state: NodeMaterialBuildState): this;
  21932. }
  21933. }
  21934. declare module BABYLON {
  21935. /**
  21936. * Block used for the particle ramp gradient section
  21937. */
  21938. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21939. /**
  21940. * Create a new ParticleRampGradientBlock
  21941. * @param name defines the block name
  21942. */
  21943. constructor(name: string);
  21944. /**
  21945. * Gets the current class name
  21946. * @returns the class name
  21947. */
  21948. getClassName(): string;
  21949. /**
  21950. * Gets the color input component
  21951. */
  21952. get color(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the rampColor output component
  21955. */
  21956. get rampColor(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Initialize the block and prepare the context for build
  21959. * @param state defines the state that will be used for the build
  21960. */
  21961. initialize(state: NodeMaterialBuildState): void;
  21962. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21963. }
  21964. }
  21965. declare module BABYLON {
  21966. /**
  21967. * Block used for the particle blend multiply section
  21968. */
  21969. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21970. /**
  21971. * Create a new ParticleBlendMultiplyBlock
  21972. * @param name defines the block name
  21973. */
  21974. constructor(name: string);
  21975. /**
  21976. * Gets the current class name
  21977. * @returns the class name
  21978. */
  21979. getClassName(): string;
  21980. /**
  21981. * Gets the color input component
  21982. */
  21983. get color(): NodeMaterialConnectionPoint;
  21984. /**
  21985. * Gets the alphaTexture input component
  21986. */
  21987. get alphaTexture(): NodeMaterialConnectionPoint;
  21988. /**
  21989. * Gets the alphaColor input component
  21990. */
  21991. get alphaColor(): NodeMaterialConnectionPoint;
  21992. /**
  21993. * Gets the blendColor output component
  21994. */
  21995. get blendColor(): NodeMaterialConnectionPoint;
  21996. /**
  21997. * Initialize the block and prepare the context for build
  21998. * @param state defines the state that will be used for the build
  21999. */
  22000. initialize(state: NodeMaterialBuildState): void;
  22001. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22002. }
  22003. }
  22004. declare module BABYLON {
  22005. /**
  22006. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22007. */
  22008. export class VectorMergerBlock extends NodeMaterialBlock {
  22009. /**
  22010. * Create a new VectorMergerBlock
  22011. * @param name defines the block name
  22012. */
  22013. constructor(name: string);
  22014. /**
  22015. * Gets the current class name
  22016. * @returns the class name
  22017. */
  22018. getClassName(): string;
  22019. /**
  22020. * Gets the xyz component (input)
  22021. */
  22022. get xyzIn(): NodeMaterialConnectionPoint;
  22023. /**
  22024. * Gets the xy component (input)
  22025. */
  22026. get xyIn(): NodeMaterialConnectionPoint;
  22027. /**
  22028. * Gets the x component (input)
  22029. */
  22030. get x(): NodeMaterialConnectionPoint;
  22031. /**
  22032. * Gets the y component (input)
  22033. */
  22034. get y(): NodeMaterialConnectionPoint;
  22035. /**
  22036. * Gets the z component (input)
  22037. */
  22038. get z(): NodeMaterialConnectionPoint;
  22039. /**
  22040. * Gets the w component (input)
  22041. */
  22042. get w(): NodeMaterialConnectionPoint;
  22043. /**
  22044. * Gets the xyzw component (output)
  22045. */
  22046. get xyzw(): NodeMaterialConnectionPoint;
  22047. /**
  22048. * Gets the xyz component (output)
  22049. */
  22050. get xyzOut(): NodeMaterialConnectionPoint;
  22051. /**
  22052. * Gets the xy component (output)
  22053. */
  22054. get xyOut(): NodeMaterialConnectionPoint;
  22055. /**
  22056. * Gets the xy component (output)
  22057. * @deprecated Please use xyOut instead.
  22058. */
  22059. get xy(): NodeMaterialConnectionPoint;
  22060. /**
  22061. * Gets the xyz component (output)
  22062. * @deprecated Please use xyzOut instead.
  22063. */
  22064. get xyz(): NodeMaterialConnectionPoint;
  22065. protected _buildBlock(state: NodeMaterialBuildState): this;
  22066. }
  22067. }
  22068. declare module BABYLON {
  22069. /**
  22070. * Block used to remap a float from a range to a new one
  22071. */
  22072. export class RemapBlock extends NodeMaterialBlock {
  22073. /**
  22074. * Gets or sets the source range
  22075. */
  22076. sourceRange: Vector2;
  22077. /**
  22078. * Gets or sets the target range
  22079. */
  22080. targetRange: Vector2;
  22081. /**
  22082. * Creates a new RemapBlock
  22083. * @param name defines the block name
  22084. */
  22085. constructor(name: string);
  22086. /**
  22087. * Gets the current class name
  22088. * @returns the class name
  22089. */
  22090. getClassName(): string;
  22091. /**
  22092. * Gets the input component
  22093. */
  22094. get input(): NodeMaterialConnectionPoint;
  22095. /**
  22096. * Gets the source min input component
  22097. */
  22098. get sourceMin(): NodeMaterialConnectionPoint;
  22099. /**
  22100. * Gets the source max input component
  22101. */
  22102. get sourceMax(): NodeMaterialConnectionPoint;
  22103. /**
  22104. * Gets the target min input component
  22105. */
  22106. get targetMin(): NodeMaterialConnectionPoint;
  22107. /**
  22108. * Gets the target max input component
  22109. */
  22110. get targetMax(): NodeMaterialConnectionPoint;
  22111. /**
  22112. * Gets the output component
  22113. */
  22114. get output(): NodeMaterialConnectionPoint;
  22115. protected _buildBlock(state: NodeMaterialBuildState): this;
  22116. protected _dumpPropertiesCode(): string;
  22117. serialize(): any;
  22118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22119. }
  22120. }
  22121. declare module BABYLON {
  22122. /**
  22123. * Block used to multiply 2 values
  22124. */
  22125. export class MultiplyBlock extends NodeMaterialBlock {
  22126. /**
  22127. * Creates a new MultiplyBlock
  22128. * @param name defines the block name
  22129. */
  22130. constructor(name: string);
  22131. /**
  22132. * Gets the current class name
  22133. * @returns the class name
  22134. */
  22135. getClassName(): string;
  22136. /**
  22137. * Gets the left operand input component
  22138. */
  22139. get left(): NodeMaterialConnectionPoint;
  22140. /**
  22141. * Gets the right operand input component
  22142. */
  22143. get right(): NodeMaterialConnectionPoint;
  22144. /**
  22145. * Gets the output component
  22146. */
  22147. get output(): NodeMaterialConnectionPoint;
  22148. protected _buildBlock(state: NodeMaterialBuildState): this;
  22149. }
  22150. }
  22151. declare module BABYLON {
  22152. /**
  22153. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22154. */
  22155. export class ColorSplitterBlock extends NodeMaterialBlock {
  22156. /**
  22157. * Create a new ColorSplitterBlock
  22158. * @param name defines the block name
  22159. */
  22160. constructor(name: string);
  22161. /**
  22162. * Gets the current class name
  22163. * @returns the class name
  22164. */
  22165. getClassName(): string;
  22166. /**
  22167. * Gets the rgba component (input)
  22168. */
  22169. get rgba(): NodeMaterialConnectionPoint;
  22170. /**
  22171. * Gets the rgb component (input)
  22172. */
  22173. get rgbIn(): NodeMaterialConnectionPoint;
  22174. /**
  22175. * Gets the rgb component (output)
  22176. */
  22177. get rgbOut(): NodeMaterialConnectionPoint;
  22178. /**
  22179. * Gets the r component (output)
  22180. */
  22181. get r(): NodeMaterialConnectionPoint;
  22182. /**
  22183. * Gets the g component (output)
  22184. */
  22185. get g(): NodeMaterialConnectionPoint;
  22186. /**
  22187. * Gets the b component (output)
  22188. */
  22189. get b(): NodeMaterialConnectionPoint;
  22190. /**
  22191. * Gets the a component (output)
  22192. */
  22193. get a(): NodeMaterialConnectionPoint;
  22194. protected _inputRename(name: string): string;
  22195. protected _outputRename(name: string): string;
  22196. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22197. }
  22198. }
  22199. declare module BABYLON {
  22200. /**
  22201. * Interface used to configure the node material editor
  22202. */
  22203. export interface INodeMaterialEditorOptions {
  22204. /** Define the URl to load node editor script */
  22205. editorURL?: string;
  22206. }
  22207. /** @hidden */
  22208. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22209. NORMAL: boolean;
  22210. TANGENT: boolean;
  22211. UV1: boolean;
  22212. /** BONES */
  22213. NUM_BONE_INFLUENCERS: number;
  22214. BonesPerMesh: number;
  22215. BONETEXTURE: boolean;
  22216. /** MORPH TARGETS */
  22217. MORPHTARGETS: boolean;
  22218. MORPHTARGETS_NORMAL: boolean;
  22219. MORPHTARGETS_TANGENT: boolean;
  22220. MORPHTARGETS_UV: boolean;
  22221. NUM_MORPH_INFLUENCERS: number;
  22222. /** IMAGE PROCESSING */
  22223. IMAGEPROCESSING: boolean;
  22224. VIGNETTE: boolean;
  22225. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22226. VIGNETTEBLENDMODEOPAQUE: boolean;
  22227. TONEMAPPING: boolean;
  22228. TONEMAPPING_ACES: boolean;
  22229. CONTRAST: boolean;
  22230. EXPOSURE: boolean;
  22231. COLORCURVES: boolean;
  22232. COLORGRADING: boolean;
  22233. COLORGRADING3D: boolean;
  22234. SAMPLER3DGREENDEPTH: boolean;
  22235. SAMPLER3DBGRMAP: boolean;
  22236. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22237. /** MISC. */
  22238. BUMPDIRECTUV: number;
  22239. constructor();
  22240. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22241. }
  22242. /**
  22243. * Class used to configure NodeMaterial
  22244. */
  22245. export interface INodeMaterialOptions {
  22246. /**
  22247. * Defines if blocks should emit comments
  22248. */
  22249. emitComments: boolean;
  22250. }
  22251. /**
  22252. * Class used to create a node based material built by assembling shader blocks
  22253. */
  22254. export class NodeMaterial extends PushMaterial {
  22255. private static _BuildIdGenerator;
  22256. private _options;
  22257. private _vertexCompilationState;
  22258. private _fragmentCompilationState;
  22259. private _sharedData;
  22260. private _buildId;
  22261. private _buildWasSuccessful;
  22262. private _cachedWorldViewMatrix;
  22263. private _cachedWorldViewProjectionMatrix;
  22264. private _optimizers;
  22265. private _animationFrame;
  22266. /** Define the Url to load node editor script */
  22267. static EditorURL: string;
  22268. /** Define the Url to load snippets */
  22269. static SnippetUrl: string;
  22270. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22271. static IgnoreTexturesAtLoadTime: boolean;
  22272. private BJSNODEMATERIALEDITOR;
  22273. /** Get the inspector from bundle or global */
  22274. private _getGlobalNodeMaterialEditor;
  22275. /**
  22276. * Snippet ID if the material was created from the snippet server
  22277. */
  22278. snippetId: string;
  22279. /**
  22280. * Gets or sets data used by visual editor
  22281. * @see https://nme.babylonjs.com
  22282. */
  22283. editorData: any;
  22284. /**
  22285. * 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)
  22286. */
  22287. ignoreAlpha: boolean;
  22288. /**
  22289. * Defines the maximum number of lights that can be used in the material
  22290. */
  22291. maxSimultaneousLights: number;
  22292. /**
  22293. * Observable raised when the material is built
  22294. */
  22295. onBuildObservable: Observable<NodeMaterial>;
  22296. /**
  22297. * Gets or sets the root nodes of the material vertex shader
  22298. */
  22299. _vertexOutputNodes: NodeMaterialBlock[];
  22300. /**
  22301. * Gets or sets the root nodes of the material fragment (pixel) shader
  22302. */
  22303. _fragmentOutputNodes: NodeMaterialBlock[];
  22304. /** Gets or sets options to control the node material overall behavior */
  22305. get options(): INodeMaterialOptions;
  22306. set options(options: INodeMaterialOptions);
  22307. /**
  22308. * Default configuration related to image processing available in the standard Material.
  22309. */
  22310. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22311. /**
  22312. * Gets the image processing configuration used either in this material.
  22313. */
  22314. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22315. /**
  22316. * Sets the Default image processing configuration used either in the this material.
  22317. *
  22318. * If sets to null, the scene one is in use.
  22319. */
  22320. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22321. /**
  22322. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22323. */
  22324. attachedBlocks: NodeMaterialBlock[];
  22325. /**
  22326. * Specifies the mode of the node material
  22327. * @hidden
  22328. */
  22329. _mode: NodeMaterialModes;
  22330. /**
  22331. * Gets the mode property
  22332. */
  22333. get mode(): NodeMaterialModes;
  22334. /**
  22335. * Create a new node based material
  22336. * @param name defines the material name
  22337. * @param scene defines the hosting scene
  22338. * @param options defines creation option
  22339. */
  22340. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22341. /**
  22342. * Gets the current class name of the material e.g. "NodeMaterial"
  22343. * @returns the class name
  22344. */
  22345. getClassName(): string;
  22346. /**
  22347. * Keep track of the image processing observer to allow dispose and replace.
  22348. */
  22349. private _imageProcessingObserver;
  22350. /**
  22351. * Attaches a new image processing configuration to the Standard Material.
  22352. * @param configuration
  22353. */
  22354. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22355. /**
  22356. * Get a block by its name
  22357. * @param name defines the name of the block to retrieve
  22358. * @returns the required block or null if not found
  22359. */
  22360. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22361. /**
  22362. * Get a block by its name
  22363. * @param predicate defines the predicate used to find the good candidate
  22364. * @returns the required block or null if not found
  22365. */
  22366. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22367. /**
  22368. * Get an input block by its name
  22369. * @param predicate defines the predicate used to find the good candidate
  22370. * @returns the required input block or null if not found
  22371. */
  22372. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22373. /**
  22374. * Gets the list of input blocks attached to this material
  22375. * @returns an array of InputBlocks
  22376. */
  22377. getInputBlocks(): InputBlock[];
  22378. /**
  22379. * Adds a new optimizer to the list of optimizers
  22380. * @param optimizer defines the optimizers to add
  22381. * @returns the current material
  22382. */
  22383. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22384. /**
  22385. * Remove an optimizer from the list of optimizers
  22386. * @param optimizer defines the optimizers to remove
  22387. * @returns the current material
  22388. */
  22389. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22390. /**
  22391. * Add a new block to the list of output nodes
  22392. * @param node defines the node to add
  22393. * @returns the current material
  22394. */
  22395. addOutputNode(node: NodeMaterialBlock): this;
  22396. /**
  22397. * Remove a block from the list of root nodes
  22398. * @param node defines the node to remove
  22399. * @returns the current material
  22400. */
  22401. removeOutputNode(node: NodeMaterialBlock): this;
  22402. private _addVertexOutputNode;
  22403. private _removeVertexOutputNode;
  22404. private _addFragmentOutputNode;
  22405. private _removeFragmentOutputNode;
  22406. /**
  22407. * Specifies if the material will require alpha blending
  22408. * @returns a boolean specifying if alpha blending is needed
  22409. */
  22410. needAlphaBlending(): boolean;
  22411. /**
  22412. * Specifies if this material should be rendered in alpha test mode
  22413. * @returns a boolean specifying if an alpha test is needed.
  22414. */
  22415. needAlphaTesting(): boolean;
  22416. private _initializeBlock;
  22417. private _resetDualBlocks;
  22418. /**
  22419. * Remove a block from the current node material
  22420. * @param block defines the block to remove
  22421. */
  22422. removeBlock(block: NodeMaterialBlock): void;
  22423. /**
  22424. * Build the material and generates the inner effect
  22425. * @param verbose defines if the build should log activity
  22426. */
  22427. build(verbose?: boolean): void;
  22428. /**
  22429. * Runs an otpimization phase to try to improve the shader code
  22430. */
  22431. optimize(): void;
  22432. private _prepareDefinesForAttributes;
  22433. /**
  22434. * Create a post process from the material
  22435. * @param camera The camera to apply the render pass to.
  22436. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22438. * @param engine The engine which the post process will be applied. (default: current engine)
  22439. * @param reusable If the post process can be reused on the same frame. (default: false)
  22440. * @param textureType Type of textures used when performing the post process. (default: 0)
  22441. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22442. * @returns the post process created
  22443. */
  22444. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22445. /**
  22446. * Create the post process effect from the material
  22447. * @param postProcess The post process to create the effect for
  22448. */
  22449. createEffectForPostProcess(postProcess: PostProcess): void;
  22450. private _createEffectOrPostProcess;
  22451. private _createEffectForParticles;
  22452. /**
  22453. * Create the effect to be used as the custom effect for a particle system
  22454. * @param particleSystem Particle system to create the effect for
  22455. * @param onCompiled defines a function to call when the effect creation is successful
  22456. * @param onError defines a function to call when the effect creation has failed
  22457. */
  22458. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22459. private _processDefines;
  22460. /**
  22461. * Get if the submesh is ready to be used and all its information available.
  22462. * Child classes can use it to update shaders
  22463. * @param mesh defines the mesh to check
  22464. * @param subMesh defines which submesh to check
  22465. * @param useInstances specifies that instances should be used
  22466. * @returns a boolean indicating that the submesh is ready or not
  22467. */
  22468. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22469. /**
  22470. * Get a string representing the shaders built by the current node graph
  22471. */
  22472. get compiledShaders(): string;
  22473. /**
  22474. * Binds the world matrix to the material
  22475. * @param world defines the world transformation matrix
  22476. */
  22477. bindOnlyWorldMatrix(world: Matrix): void;
  22478. /**
  22479. * Binds the submesh to this material by preparing the effect and shader to draw
  22480. * @param world defines the world transformation matrix
  22481. * @param mesh defines the mesh containing the submesh
  22482. * @param subMesh defines the submesh to bind the material to
  22483. */
  22484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22485. /**
  22486. * Gets the active textures from the material
  22487. * @returns an array of textures
  22488. */
  22489. getActiveTextures(): BaseTexture[];
  22490. /**
  22491. * Gets the list of texture blocks
  22492. * @returns an array of texture blocks
  22493. */
  22494. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22495. /**
  22496. * Specifies if the material uses a texture
  22497. * @param texture defines the texture to check against the material
  22498. * @returns a boolean specifying if the material uses the texture
  22499. */
  22500. hasTexture(texture: BaseTexture): boolean;
  22501. /**
  22502. * Disposes the material
  22503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22505. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22506. */
  22507. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22508. /** Creates the node editor window. */
  22509. private _createNodeEditor;
  22510. /**
  22511. * Launch the node material editor
  22512. * @param config Define the configuration of the editor
  22513. * @return a promise fulfilled when the node editor is visible
  22514. */
  22515. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22516. /**
  22517. * Clear the current material
  22518. */
  22519. clear(): void;
  22520. /**
  22521. * Clear the current material and set it to a default state
  22522. */
  22523. setToDefault(): void;
  22524. /**
  22525. * Clear the current material and set it to a default state for post process
  22526. */
  22527. setToDefaultPostProcess(): void;
  22528. /**
  22529. * Clear the current material and set it to a default state for particle
  22530. */
  22531. setToDefaultParticle(): void;
  22532. /**
  22533. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22534. * @param url defines the url to load from
  22535. * @returns a promise that will fullfil when the material is fully loaded
  22536. */
  22537. loadAsync(url: string): Promise<void>;
  22538. private _gatherBlocks;
  22539. /**
  22540. * Generate a string containing the code declaration required to create an equivalent of this material
  22541. * @returns a string
  22542. */
  22543. generateCode(): string;
  22544. /**
  22545. * Serializes this material in a JSON representation
  22546. * @returns the serialized material object
  22547. */
  22548. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22549. private _restoreConnections;
  22550. /**
  22551. * Clear the current graph and load a new one from a serialization object
  22552. * @param source defines the JSON representation of the material
  22553. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22554. * @param merge defines whether or not the source must be merged or replace the current content
  22555. */
  22556. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22557. /**
  22558. * Makes a duplicate of the current material.
  22559. * @param name - name to use for the new material.
  22560. */
  22561. clone(name: string): NodeMaterial;
  22562. /**
  22563. * Creates a node material from parsed material data
  22564. * @param source defines the JSON representation of the material
  22565. * @param scene defines the hosting scene
  22566. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22567. * @returns a new node material
  22568. */
  22569. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22570. /**
  22571. * Creates a node material from a snippet saved in a remote file
  22572. * @param name defines the name of the material to create
  22573. * @param url defines the url to load from
  22574. * @param scene defines the hosting scene
  22575. * @returns a promise that will resolve to the new node material
  22576. */
  22577. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22578. /**
  22579. * Creates a node material from a snippet saved by the node material editor
  22580. * @param snippetId defines the snippet to load
  22581. * @param scene defines the hosting scene
  22582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22583. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22584. * @returns a promise that will resolve to the new node material
  22585. */
  22586. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22587. /**
  22588. * Creates a new node material set to default basic configuration
  22589. * @param name defines the name of the material
  22590. * @param scene defines the hosting scene
  22591. * @returns a new NodeMaterial
  22592. */
  22593. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22594. }
  22595. }
  22596. declare module BABYLON {
  22597. /**
  22598. * Size options for a post process
  22599. */
  22600. export type PostProcessOptions = {
  22601. width: number;
  22602. height: number;
  22603. };
  22604. /**
  22605. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22606. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22607. */
  22608. export class PostProcess {
  22609. /**
  22610. * Gets or sets the unique id of the post process
  22611. */
  22612. uniqueId: number;
  22613. /** Name of the PostProcess. */
  22614. name: string;
  22615. /**
  22616. * Width of the texture to apply the post process on
  22617. */
  22618. width: number;
  22619. /**
  22620. * Height of the texture to apply the post process on
  22621. */
  22622. height: number;
  22623. /**
  22624. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22625. */
  22626. nodeMaterialSource: Nullable<NodeMaterial>;
  22627. /**
  22628. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22629. * @hidden
  22630. */
  22631. _outputTexture: Nullable<InternalTexture>;
  22632. /**
  22633. * Sampling mode used by the shader
  22634. * See https://doc.babylonjs.com/classes/3.1/texture
  22635. */
  22636. renderTargetSamplingMode: number;
  22637. /**
  22638. * Clear color to use when screen clearing
  22639. */
  22640. clearColor: Color4;
  22641. /**
  22642. * If the buffer needs to be cleared before applying the post process. (default: true)
  22643. * Should be set to false if shader will overwrite all previous pixels.
  22644. */
  22645. autoClear: boolean;
  22646. /**
  22647. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22648. */
  22649. alphaMode: number;
  22650. /**
  22651. * Sets the setAlphaBlendConstants of the babylon engine
  22652. */
  22653. alphaConstants: Color4;
  22654. /**
  22655. * Animations to be used for the post processing
  22656. */
  22657. animations: Animation[];
  22658. /**
  22659. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22660. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22661. */
  22662. enablePixelPerfectMode: boolean;
  22663. /**
  22664. * Force the postprocess to be applied without taking in account viewport
  22665. */
  22666. forceFullscreenViewport: boolean;
  22667. /**
  22668. * List of inspectable custom properties (used by the Inspector)
  22669. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22670. */
  22671. inspectableCustomProperties: IInspectable[];
  22672. /**
  22673. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22674. *
  22675. * | Value | Type | Description |
  22676. * | ----- | ----------------------------------- | ----------- |
  22677. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22678. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22679. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22680. *
  22681. */
  22682. scaleMode: number;
  22683. /**
  22684. * Force textures to be a power of two (default: false)
  22685. */
  22686. alwaysForcePOT: boolean;
  22687. private _samples;
  22688. /**
  22689. * Number of sample textures (default: 1)
  22690. */
  22691. get samples(): number;
  22692. set samples(n: number);
  22693. /**
  22694. * Modify the scale of the post process to be the same as the viewport (default: false)
  22695. */
  22696. adaptScaleToCurrentViewport: boolean;
  22697. private _camera;
  22698. protected _scene: Scene;
  22699. private _engine;
  22700. private _options;
  22701. private _reusable;
  22702. private _textureType;
  22703. private _textureFormat;
  22704. /**
  22705. * Smart array of input and output textures for the post process.
  22706. * @hidden
  22707. */
  22708. _textures: SmartArray<InternalTexture>;
  22709. /**
  22710. * The index in _textures that corresponds to the output texture.
  22711. * @hidden
  22712. */
  22713. _currentRenderTextureInd: number;
  22714. private _effect;
  22715. private _samplers;
  22716. private _fragmentUrl;
  22717. private _vertexUrl;
  22718. private _parameters;
  22719. private _scaleRatio;
  22720. protected _indexParameters: any;
  22721. private _shareOutputWithPostProcess;
  22722. private _texelSize;
  22723. private _forcedOutputTexture;
  22724. /**
  22725. * Returns the fragment url or shader name used in the post process.
  22726. * @returns the fragment url or name in the shader store.
  22727. */
  22728. getEffectName(): string;
  22729. /**
  22730. * An event triggered when the postprocess is activated.
  22731. */
  22732. onActivateObservable: Observable<Camera>;
  22733. private _onActivateObserver;
  22734. /**
  22735. * A function that is added to the onActivateObservable
  22736. */
  22737. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22738. /**
  22739. * An event triggered when the postprocess changes its size.
  22740. */
  22741. onSizeChangedObservable: Observable<PostProcess>;
  22742. private _onSizeChangedObserver;
  22743. /**
  22744. * A function that is added to the onSizeChangedObservable
  22745. */
  22746. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22747. /**
  22748. * An event triggered when the postprocess applies its effect.
  22749. */
  22750. onApplyObservable: Observable<Effect>;
  22751. private _onApplyObserver;
  22752. /**
  22753. * A function that is added to the onApplyObservable
  22754. */
  22755. set onApply(callback: (effect: Effect) => void);
  22756. /**
  22757. * An event triggered before rendering the postprocess
  22758. */
  22759. onBeforeRenderObservable: Observable<Effect>;
  22760. private _onBeforeRenderObserver;
  22761. /**
  22762. * A function that is added to the onBeforeRenderObservable
  22763. */
  22764. set onBeforeRender(callback: (effect: Effect) => void);
  22765. /**
  22766. * An event triggered after rendering the postprocess
  22767. */
  22768. onAfterRenderObservable: Observable<Effect>;
  22769. private _onAfterRenderObserver;
  22770. /**
  22771. * A function that is added to the onAfterRenderObservable
  22772. */
  22773. set onAfterRender(callback: (efect: Effect) => void);
  22774. /**
  22775. * 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
  22776. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22777. */
  22778. get inputTexture(): InternalTexture;
  22779. set inputTexture(value: InternalTexture);
  22780. /**
  22781. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22782. * the only way to unset it is to use this function to restore its internal state
  22783. */
  22784. restoreDefaultInputTexture(): void;
  22785. /**
  22786. * Gets the camera which post process is applied to.
  22787. * @returns The camera the post process is applied to.
  22788. */
  22789. getCamera(): Camera;
  22790. /**
  22791. * Gets the texel size of the postprocess.
  22792. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22793. */
  22794. get texelSize(): Vector2;
  22795. /**
  22796. * Creates a new instance PostProcess
  22797. * @param name The name of the PostProcess.
  22798. * @param fragmentUrl The url of the fragment shader to be used.
  22799. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22800. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22801. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22802. * @param camera The camera to apply the render pass to.
  22803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22804. * @param engine The engine which the post process will be applied. (default: current engine)
  22805. * @param reusable If the post process can be reused on the same frame. (default: false)
  22806. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22807. * @param textureType Type of textures used when performing the post process. (default: 0)
  22808. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22809. * @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
  22810. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22811. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22812. */
  22813. 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);
  22814. /**
  22815. * Gets a string identifying the name of the class
  22816. * @returns "PostProcess" string
  22817. */
  22818. getClassName(): string;
  22819. /**
  22820. * Gets the engine which this post process belongs to.
  22821. * @returns The engine the post process was enabled with.
  22822. */
  22823. getEngine(): Engine;
  22824. /**
  22825. * The effect that is created when initializing the post process.
  22826. * @returns The created effect corresponding the the postprocess.
  22827. */
  22828. getEffect(): Effect;
  22829. /**
  22830. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22831. * @param postProcess The post process to share the output with.
  22832. * @returns This post process.
  22833. */
  22834. shareOutputWith(postProcess: PostProcess): PostProcess;
  22835. /**
  22836. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22837. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22838. */
  22839. useOwnOutput(): void;
  22840. /**
  22841. * Updates the effect with the current post process compile time values and recompiles the shader.
  22842. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22843. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22844. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22845. * @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
  22846. * @param onCompiled Called when the shader has been compiled.
  22847. * @param onError Called if there is an error when compiling a shader.
  22848. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22849. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22850. */
  22851. 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;
  22852. /**
  22853. * The post process is reusable if it can be used multiple times within one frame.
  22854. * @returns If the post process is reusable
  22855. */
  22856. isReusable(): boolean;
  22857. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22858. markTextureDirty(): void;
  22859. /**
  22860. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22861. * 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.
  22862. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22863. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22864. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22865. * @returns The target texture that was bound to be written to.
  22866. */
  22867. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22868. /**
  22869. * If the post process is supported.
  22870. */
  22871. get isSupported(): boolean;
  22872. /**
  22873. * The aspect ratio of the output texture.
  22874. */
  22875. get aspectRatio(): number;
  22876. /**
  22877. * Get a value indicating if the post-process is ready to be used
  22878. * @returns true if the post-process is ready (shader is compiled)
  22879. */
  22880. isReady(): boolean;
  22881. /**
  22882. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22883. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22884. */
  22885. apply(): Nullable<Effect>;
  22886. private _disposeTextures;
  22887. /**
  22888. * Disposes the post process.
  22889. * @param camera The camera to dispose the post process on.
  22890. */
  22891. dispose(camera?: Camera): void;
  22892. /**
  22893. * Serializes the particle system to a JSON object
  22894. * @returns the JSON object
  22895. */
  22896. serialize(): any;
  22897. /**
  22898. * Creates a material from parsed material data
  22899. * @param parsedPostProcess defines parsed post process data
  22900. * @param scene defines the hosting scene
  22901. * @param rootUrl defines the root URL to use to load textures
  22902. * @returns a new post process
  22903. */
  22904. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22905. }
  22906. }
  22907. declare module BABYLON {
  22908. /** @hidden */
  22909. export var kernelBlurVaryingDeclaration: {
  22910. name: string;
  22911. shader: string;
  22912. };
  22913. }
  22914. declare module BABYLON {
  22915. /** @hidden */
  22916. export var kernelBlurFragment: {
  22917. name: string;
  22918. shader: string;
  22919. };
  22920. }
  22921. declare module BABYLON {
  22922. /** @hidden */
  22923. export var kernelBlurFragment2: {
  22924. name: string;
  22925. shader: string;
  22926. };
  22927. }
  22928. declare module BABYLON {
  22929. /** @hidden */
  22930. export var kernelBlurPixelShader: {
  22931. name: string;
  22932. shader: string;
  22933. };
  22934. }
  22935. declare module BABYLON {
  22936. /** @hidden */
  22937. export var kernelBlurVertex: {
  22938. name: string;
  22939. shader: string;
  22940. };
  22941. }
  22942. declare module BABYLON {
  22943. /** @hidden */
  22944. export var kernelBlurVertexShader: {
  22945. name: string;
  22946. shader: string;
  22947. };
  22948. }
  22949. declare module BABYLON {
  22950. /**
  22951. * The Blur Post Process which blurs an image based on a kernel and direction.
  22952. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22953. */
  22954. export class BlurPostProcess extends PostProcess {
  22955. private blockCompilation;
  22956. protected _kernel: number;
  22957. protected _idealKernel: number;
  22958. protected _packedFloat: boolean;
  22959. private _staticDefines;
  22960. /** The direction in which to blur the image. */
  22961. direction: Vector2;
  22962. /**
  22963. * Sets the length in pixels of the blur sample region
  22964. */
  22965. set kernel(v: number);
  22966. /**
  22967. * Gets the length in pixels of the blur sample region
  22968. */
  22969. get kernel(): number;
  22970. /**
  22971. * Sets wether or not the blur needs to unpack/repack floats
  22972. */
  22973. set packedFloat(v: boolean);
  22974. /**
  22975. * Gets wether or not the blur is unpacking/repacking floats
  22976. */
  22977. get packedFloat(): boolean;
  22978. /**
  22979. * Gets a string identifying the name of the class
  22980. * @returns "BlurPostProcess" string
  22981. */
  22982. getClassName(): string;
  22983. /**
  22984. * Creates a new instance BlurPostProcess
  22985. * @param name The name of the effect.
  22986. * @param direction The direction in which to blur the image.
  22987. * @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.
  22988. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22989. * @param camera The camera to apply the render pass to.
  22990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22991. * @param engine The engine which the post process will be applied. (default: current engine)
  22992. * @param reusable If the post process can be reused on the same frame. (default: false)
  22993. * @param textureType Type of textures used when performing the post process. (default: 0)
  22994. * @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)
  22995. */
  22996. 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);
  22997. /**
  22998. * Updates the effect with the current post process compile time values and recompiles the shader.
  22999. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23000. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23001. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23002. * @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
  23003. * @param onCompiled Called when the shader has been compiled.
  23004. * @param onError Called if there is an error when compiling a shader.
  23005. */
  23006. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23007. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23008. /**
  23009. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23010. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23011. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23012. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23013. * The gaps between physical kernels are compensated for in the weighting of the samples
  23014. * @param idealKernel Ideal blur kernel.
  23015. * @return Nearest best kernel.
  23016. */
  23017. protected _nearestBestKernel(idealKernel: number): number;
  23018. /**
  23019. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23020. * @param x The point on the Gaussian distribution to sample.
  23021. * @return the value of the Gaussian function at x.
  23022. */
  23023. protected _gaussianWeight(x: number): number;
  23024. /**
  23025. * Generates a string that can be used as a floating point number in GLSL.
  23026. * @param x Value to print.
  23027. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23028. * @return GLSL float string.
  23029. */
  23030. protected _glslFloat(x: number, decimalFigures?: number): string;
  23031. /** @hidden */
  23032. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23033. }
  23034. }
  23035. declare module BABYLON {
  23036. /**
  23037. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23038. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23039. * You can then easily use it as a reflectionTexture on a flat surface.
  23040. * In case the surface is not a plane, please consider relying on reflection probes.
  23041. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23042. */
  23043. export class MirrorTexture extends RenderTargetTexture {
  23044. private scene;
  23045. /**
  23046. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23047. * 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.
  23048. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23049. */
  23050. mirrorPlane: Plane;
  23051. /**
  23052. * Define the blur ratio used to blur the reflection if needed.
  23053. */
  23054. set blurRatio(value: number);
  23055. get blurRatio(): number;
  23056. /**
  23057. * Define the adaptive blur kernel used to blur the reflection if needed.
  23058. * This will autocompute the closest best match for the `blurKernel`
  23059. */
  23060. set adaptiveBlurKernel(value: number);
  23061. /**
  23062. * Define the blur kernel used to blur the reflection if needed.
  23063. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23064. */
  23065. set blurKernel(value: number);
  23066. /**
  23067. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23069. */
  23070. set blurKernelX(value: number);
  23071. get blurKernelX(): number;
  23072. /**
  23073. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23074. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23075. */
  23076. set blurKernelY(value: number);
  23077. get blurKernelY(): number;
  23078. private _autoComputeBlurKernel;
  23079. protected _onRatioRescale(): void;
  23080. private _updateGammaSpace;
  23081. private _imageProcessingConfigChangeObserver;
  23082. private _transformMatrix;
  23083. private _mirrorMatrix;
  23084. private _savedViewMatrix;
  23085. private _blurX;
  23086. private _blurY;
  23087. private _adaptiveBlurKernel;
  23088. private _blurKernelX;
  23089. private _blurKernelY;
  23090. private _blurRatio;
  23091. /**
  23092. * Instantiates a Mirror Texture.
  23093. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23094. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23095. * You can then easily use it as a reflectionTexture on a flat surface.
  23096. * In case the surface is not a plane, please consider relying on reflection probes.
  23097. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23098. * @param name
  23099. * @param size
  23100. * @param scene
  23101. * @param generateMipMaps
  23102. * @param type
  23103. * @param samplingMode
  23104. * @param generateDepthBuffer
  23105. */
  23106. constructor(name: string, size: number | {
  23107. width: number;
  23108. height: number;
  23109. } | {
  23110. ratio: number;
  23111. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23112. private _preparePostProcesses;
  23113. /**
  23114. * Clone the mirror texture.
  23115. * @returns the cloned texture
  23116. */
  23117. clone(): MirrorTexture;
  23118. /**
  23119. * Serialize the texture to a JSON representation you could use in Parse later on
  23120. * @returns the serialized JSON representation
  23121. */
  23122. serialize(): any;
  23123. /**
  23124. * Dispose the texture and release its associated resources.
  23125. */
  23126. dispose(): void;
  23127. }
  23128. }
  23129. declare module BABYLON {
  23130. /**
  23131. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23132. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23133. */
  23134. export class Texture extends BaseTexture {
  23135. /**
  23136. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23137. */
  23138. static SerializeBuffers: boolean;
  23139. /** @hidden */
  23140. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23141. /** @hidden */
  23142. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23143. /** @hidden */
  23144. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23145. /** nearest is mag = nearest and min = nearest and mip = linear */
  23146. static readonly NEAREST_SAMPLINGMODE: number;
  23147. /** nearest is mag = nearest and min = nearest and mip = linear */
  23148. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23149. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23150. static readonly BILINEAR_SAMPLINGMODE: number;
  23151. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23152. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23153. /** Trilinear is mag = linear and min = linear and mip = linear */
  23154. static readonly TRILINEAR_SAMPLINGMODE: number;
  23155. /** Trilinear is mag = linear and min = linear and mip = linear */
  23156. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23157. /** mag = nearest and min = nearest and mip = nearest */
  23158. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23159. /** mag = nearest and min = linear and mip = nearest */
  23160. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23161. /** mag = nearest and min = linear and mip = linear */
  23162. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23163. /** mag = nearest and min = linear and mip = none */
  23164. static readonly NEAREST_LINEAR: number;
  23165. /** mag = nearest and min = nearest and mip = none */
  23166. static readonly NEAREST_NEAREST: number;
  23167. /** mag = linear and min = nearest and mip = nearest */
  23168. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23169. /** mag = linear and min = nearest and mip = linear */
  23170. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23171. /** mag = linear and min = linear and mip = none */
  23172. static readonly LINEAR_LINEAR: number;
  23173. /** mag = linear and min = nearest and mip = none */
  23174. static readonly LINEAR_NEAREST: number;
  23175. /** Explicit coordinates mode */
  23176. static readonly EXPLICIT_MODE: number;
  23177. /** Spherical coordinates mode */
  23178. static readonly SPHERICAL_MODE: number;
  23179. /** Planar coordinates mode */
  23180. static readonly PLANAR_MODE: number;
  23181. /** Cubic coordinates mode */
  23182. static readonly CUBIC_MODE: number;
  23183. /** Projection coordinates mode */
  23184. static readonly PROJECTION_MODE: number;
  23185. /** Inverse Cubic coordinates mode */
  23186. static readonly SKYBOX_MODE: number;
  23187. /** Inverse Cubic coordinates mode */
  23188. static readonly INVCUBIC_MODE: number;
  23189. /** Equirectangular coordinates mode */
  23190. static readonly EQUIRECTANGULAR_MODE: number;
  23191. /** Equirectangular Fixed coordinates mode */
  23192. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23193. /** Equirectangular Fixed Mirrored coordinates mode */
  23194. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23195. /** Texture is not repeating outside of 0..1 UVs */
  23196. static readonly CLAMP_ADDRESSMODE: number;
  23197. /** Texture is repeating outside of 0..1 UVs */
  23198. static readonly WRAP_ADDRESSMODE: number;
  23199. /** Texture is repeating and mirrored */
  23200. static readonly MIRROR_ADDRESSMODE: number;
  23201. /**
  23202. * 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
  23203. */
  23204. static UseSerializedUrlIfAny: boolean;
  23205. /**
  23206. * Define the url of the texture.
  23207. */
  23208. url: Nullable<string>;
  23209. /**
  23210. * Define an offset on the texture to offset the u coordinates of the UVs
  23211. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23212. */
  23213. uOffset: number;
  23214. /**
  23215. * Define an offset on the texture to offset the v coordinates of the UVs
  23216. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23217. */
  23218. vOffset: number;
  23219. /**
  23220. * Define an offset on the texture to scale the u coordinates of the UVs
  23221. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23222. */
  23223. uScale: number;
  23224. /**
  23225. * Define an offset on the texture to scale the v coordinates of the UVs
  23226. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23227. */
  23228. vScale: number;
  23229. /**
  23230. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23231. * @see https://doc.babylonjs.com/how_to/more_materials
  23232. */
  23233. uAng: number;
  23234. /**
  23235. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23236. * @see https://doc.babylonjs.com/how_to/more_materials
  23237. */
  23238. vAng: number;
  23239. /**
  23240. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23241. * @see https://doc.babylonjs.com/how_to/more_materials
  23242. */
  23243. wAng: number;
  23244. /**
  23245. * Defines the center of rotation (U)
  23246. */
  23247. uRotationCenter: number;
  23248. /**
  23249. * Defines the center of rotation (V)
  23250. */
  23251. vRotationCenter: number;
  23252. /**
  23253. * Defines the center of rotation (W)
  23254. */
  23255. wRotationCenter: number;
  23256. /**
  23257. * Are mip maps generated for this texture or not.
  23258. */
  23259. get noMipmap(): boolean;
  23260. /**
  23261. * List of inspectable custom properties (used by the Inspector)
  23262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23263. */
  23264. inspectableCustomProperties: Nullable<IInspectable[]>;
  23265. private _noMipmap;
  23266. /** @hidden */
  23267. _invertY: boolean;
  23268. private _rowGenerationMatrix;
  23269. private _cachedTextureMatrix;
  23270. private _projectionModeMatrix;
  23271. private _t0;
  23272. private _t1;
  23273. private _t2;
  23274. private _cachedUOffset;
  23275. private _cachedVOffset;
  23276. private _cachedUScale;
  23277. private _cachedVScale;
  23278. private _cachedUAng;
  23279. private _cachedVAng;
  23280. private _cachedWAng;
  23281. private _cachedProjectionMatrixId;
  23282. private _cachedCoordinatesMode;
  23283. /** @hidden */
  23284. protected _initialSamplingMode: number;
  23285. /** @hidden */
  23286. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23287. private _deleteBuffer;
  23288. protected _format: Nullable<number>;
  23289. private _delayedOnLoad;
  23290. private _delayedOnError;
  23291. private _mimeType?;
  23292. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23293. get mimeType(): string | undefined;
  23294. /**
  23295. * Observable triggered once the texture has been loaded.
  23296. */
  23297. onLoadObservable: Observable<Texture>;
  23298. protected _isBlocking: boolean;
  23299. /**
  23300. * Is the texture preventing material to render while loading.
  23301. * If false, a default texture will be used instead of the loading one during the preparation step.
  23302. */
  23303. set isBlocking(value: boolean);
  23304. get isBlocking(): boolean;
  23305. /**
  23306. * Get the current sampling mode associated with the texture.
  23307. */
  23308. get samplingMode(): number;
  23309. /**
  23310. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23311. */
  23312. get invertY(): boolean;
  23313. /**
  23314. * Instantiates a new texture.
  23315. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23316. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23317. * @param url defines the url of the picture to load as a texture
  23318. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23319. * @param noMipmap defines if the texture will require mip maps or not
  23320. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23321. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23322. * @param onLoad defines a callback triggered when the texture has been loaded
  23323. * @param onError defines a callback triggered when an error occurred during the loading session
  23324. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23325. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23326. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23327. * @param mimeType defines an optional mime type information
  23328. */
  23329. 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);
  23330. /**
  23331. * Update the url (and optional buffer) of this texture if url was null during construction.
  23332. * @param url the url of the texture
  23333. * @param buffer the buffer of the texture (defaults to null)
  23334. * @param onLoad callback called when the texture is loaded (defaults to null)
  23335. */
  23336. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23337. /**
  23338. * Finish the loading sequence of a texture flagged as delayed load.
  23339. * @hidden
  23340. */
  23341. delayLoad(): void;
  23342. private _prepareRowForTextureGeneration;
  23343. /**
  23344. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23345. * @returns the transform matrix of the texture.
  23346. */
  23347. getTextureMatrix(uBase?: number): Matrix;
  23348. /**
  23349. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23350. * @returns The reflection texture transform
  23351. */
  23352. getReflectionTextureMatrix(): Matrix;
  23353. /**
  23354. * Clones the texture.
  23355. * @returns the cloned texture
  23356. */
  23357. clone(): Texture;
  23358. /**
  23359. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23360. * @returns The JSON representation of the texture
  23361. */
  23362. serialize(): any;
  23363. /**
  23364. * Get the current class name of the texture useful for serialization or dynamic coding.
  23365. * @returns "Texture"
  23366. */
  23367. getClassName(): string;
  23368. /**
  23369. * Dispose the texture and release its associated resources.
  23370. */
  23371. dispose(): void;
  23372. /**
  23373. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23374. * @param parsedTexture Define the JSON representation of the texture
  23375. * @param scene Define the scene the parsed texture should be instantiated in
  23376. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23377. * @returns The parsed texture if successful
  23378. */
  23379. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23380. /**
  23381. * Creates a texture from its base 64 representation.
  23382. * @param data Define the base64 payload without the data: prefix
  23383. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23384. * @param scene Define the scene the texture should belong to
  23385. * @param noMipmap Forces the texture to not create mip map information if true
  23386. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23387. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23388. * @param onLoad define a callback triggered when the texture has been loaded
  23389. * @param onError define a callback triggered when an error occurred during the loading session
  23390. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23391. * @returns the created texture
  23392. */
  23393. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23394. /**
  23395. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23396. * @param data Define the base64 payload without the data: prefix
  23397. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23398. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23399. * @param scene Define the scene the texture should belong to
  23400. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23401. * @param noMipmap Forces the texture to not create mip map information if true
  23402. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23403. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23404. * @param onLoad define a callback triggered when the texture has been loaded
  23405. * @param onError define a callback triggered when an error occurred during the loading session
  23406. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23407. * @returns the created texture
  23408. */
  23409. 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;
  23410. }
  23411. }
  23412. declare module BABYLON {
  23413. /**
  23414. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23415. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23416. */
  23417. export class PostProcessManager {
  23418. private _scene;
  23419. private _indexBuffer;
  23420. private _vertexBuffers;
  23421. /**
  23422. * Creates a new instance PostProcess
  23423. * @param scene The scene that the post process is associated with.
  23424. */
  23425. constructor(scene: Scene);
  23426. private _prepareBuffers;
  23427. private _buildIndexBuffer;
  23428. /**
  23429. * Rebuilds the vertex buffers of the manager.
  23430. * @hidden
  23431. */
  23432. _rebuild(): void;
  23433. /**
  23434. * Prepares a frame to be run through a post process.
  23435. * @param sourceTexture The input texture to the post procesess. (default: null)
  23436. * @param postProcesses An array of post processes to be run. (default: null)
  23437. * @returns True if the post processes were able to be run.
  23438. * @hidden
  23439. */
  23440. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23441. /**
  23442. * Manually render a set of post processes to a texture.
  23443. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23444. * @param postProcesses An array of post processes to be run.
  23445. * @param targetTexture The target texture to render to.
  23446. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23447. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23448. * @param lodLevel defines which lod of the texture to render to
  23449. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23450. */
  23451. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23452. /**
  23453. * Finalize the result of the output of the postprocesses.
  23454. * @param doNotPresent If true the result will not be displayed to the screen.
  23455. * @param targetTexture The target texture to render to.
  23456. * @param faceIndex The index of the face to bind the target texture to.
  23457. * @param postProcesses The array of post processes to render.
  23458. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23459. * @hidden
  23460. */
  23461. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23462. /**
  23463. * Disposes of the post process manager.
  23464. */
  23465. dispose(): void;
  23466. }
  23467. }
  23468. declare module BABYLON {
  23469. /**
  23470. * This Helps creating a texture that will be created from a camera in your scene.
  23471. * It is basically a dynamic texture that could be used to create special effects for instance.
  23472. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23473. */
  23474. export class RenderTargetTexture extends Texture {
  23475. /**
  23476. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23477. */
  23478. static readonly REFRESHRATE_RENDER_ONCE: number;
  23479. /**
  23480. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23481. */
  23482. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23483. /**
  23484. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23485. * the central point of your effect and can save a lot of performances.
  23486. */
  23487. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23488. /**
  23489. * Use this predicate to dynamically define the list of mesh you want to render.
  23490. * If set, the renderList property will be overwritten.
  23491. */
  23492. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23493. private _renderList;
  23494. /**
  23495. * Use this list to define the list of mesh you want to render.
  23496. */
  23497. get renderList(): Nullable<Array<AbstractMesh>>;
  23498. set renderList(value: Nullable<Array<AbstractMesh>>);
  23499. /**
  23500. * Use this function to overload the renderList array at rendering time.
  23501. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23502. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23503. * the cube (if the RTT is a cube, else layerOrFace=0).
  23504. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23505. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23506. * hold dummy elements!
  23507. */
  23508. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23509. private _hookArray;
  23510. /**
  23511. * Define if particles should be rendered in your texture.
  23512. */
  23513. renderParticles: boolean;
  23514. /**
  23515. * Define if sprites should be rendered in your texture.
  23516. */
  23517. renderSprites: boolean;
  23518. /**
  23519. * Define the camera used to render the texture.
  23520. */
  23521. activeCamera: Nullable<Camera>;
  23522. /**
  23523. * Override the mesh isReady function with your own one.
  23524. */
  23525. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23526. /**
  23527. * Override the render function of the texture with your own one.
  23528. */
  23529. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23530. /**
  23531. * Define if camera post processes should be use while rendering the texture.
  23532. */
  23533. useCameraPostProcesses: boolean;
  23534. /**
  23535. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23536. */
  23537. ignoreCameraViewport: boolean;
  23538. private _postProcessManager;
  23539. private _postProcesses;
  23540. private _resizeObserver;
  23541. /**
  23542. * An event triggered when the texture is unbind.
  23543. */
  23544. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23545. /**
  23546. * An event triggered when the texture is unbind.
  23547. */
  23548. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23549. private _onAfterUnbindObserver;
  23550. /**
  23551. * Set a after unbind callback in the texture.
  23552. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23553. */
  23554. set onAfterUnbind(callback: () => void);
  23555. /**
  23556. * An event triggered before rendering the texture
  23557. */
  23558. onBeforeRenderObservable: Observable<number>;
  23559. private _onBeforeRenderObserver;
  23560. /**
  23561. * Set a before render callback in the texture.
  23562. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23563. */
  23564. set onBeforeRender(callback: (faceIndex: number) => void);
  23565. /**
  23566. * An event triggered after rendering the texture
  23567. */
  23568. onAfterRenderObservable: Observable<number>;
  23569. private _onAfterRenderObserver;
  23570. /**
  23571. * Set a after render callback in the texture.
  23572. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23573. */
  23574. set onAfterRender(callback: (faceIndex: number) => void);
  23575. /**
  23576. * An event triggered after the texture clear
  23577. */
  23578. onClearObservable: Observable<Engine>;
  23579. private _onClearObserver;
  23580. /**
  23581. * Set a clear callback in the texture.
  23582. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23583. */
  23584. set onClear(callback: (Engine: Engine) => void);
  23585. /**
  23586. * An event triggered when the texture is resized.
  23587. */
  23588. onResizeObservable: Observable<RenderTargetTexture>;
  23589. /**
  23590. * Define the clear color of the Render Target if it should be different from the scene.
  23591. */
  23592. clearColor: Color4;
  23593. protected _size: number | {
  23594. width: number;
  23595. height: number;
  23596. layers?: number;
  23597. };
  23598. protected _initialSizeParameter: number | {
  23599. width: number;
  23600. height: number;
  23601. } | {
  23602. ratio: number;
  23603. };
  23604. protected _sizeRatio: Nullable<number>;
  23605. /** @hidden */
  23606. _generateMipMaps: boolean;
  23607. protected _renderingManager: RenderingManager;
  23608. /** @hidden */
  23609. _waitingRenderList?: string[];
  23610. protected _doNotChangeAspectRatio: boolean;
  23611. protected _currentRefreshId: number;
  23612. protected _refreshRate: number;
  23613. protected _textureMatrix: Matrix;
  23614. protected _samples: number;
  23615. protected _renderTargetOptions: RenderTargetCreationOptions;
  23616. /**
  23617. * Gets render target creation options that were used.
  23618. */
  23619. get renderTargetOptions(): RenderTargetCreationOptions;
  23620. protected _onRatioRescale(): void;
  23621. /**
  23622. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23623. * It must define where the camera used to render the texture is set
  23624. */
  23625. boundingBoxPosition: Vector3;
  23626. private _boundingBoxSize;
  23627. /**
  23628. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23629. * When defined, the cubemap will switch to local mode
  23630. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23631. * @example https://www.babylonjs-playground.com/#RNASML
  23632. */
  23633. set boundingBoxSize(value: Vector3);
  23634. get boundingBoxSize(): Vector3;
  23635. /**
  23636. * In case the RTT has been created with a depth texture, get the associated
  23637. * depth texture.
  23638. * Otherwise, return null.
  23639. */
  23640. get depthStencilTexture(): Nullable<InternalTexture>;
  23641. /**
  23642. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23643. * or used a shadow, depth texture...
  23644. * @param name The friendly name of the texture
  23645. * @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)
  23646. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23647. * @param generateMipMaps True if mip maps need to be generated after render.
  23648. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23649. * @param type The type of the buffer in the RTT (int, half float, float...)
  23650. * @param isCube True if a cube texture needs to be created
  23651. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23652. * @param generateDepthBuffer True to generate a depth buffer
  23653. * @param generateStencilBuffer True to generate a stencil buffer
  23654. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23655. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23656. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23657. */
  23658. constructor(name: string, size: number | {
  23659. width: number;
  23660. height: number;
  23661. layers?: number;
  23662. } | {
  23663. ratio: number;
  23664. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23665. /**
  23666. * Creates a depth stencil texture.
  23667. * This is only available in WebGL 2 or with the depth texture extension available.
  23668. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23669. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23670. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23671. */
  23672. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23673. private _processSizeParameter;
  23674. /**
  23675. * Define the number of samples to use in case of MSAA.
  23676. * It defaults to one meaning no MSAA has been enabled.
  23677. */
  23678. get samples(): number;
  23679. set samples(value: number);
  23680. /**
  23681. * Resets the refresh counter of the texture and start bak from scratch.
  23682. * Could be useful to regenerate the texture if it is setup to render only once.
  23683. */
  23684. resetRefreshCounter(): void;
  23685. /**
  23686. * Define the refresh rate of the texture or the rendering frequency.
  23687. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23688. */
  23689. get refreshRate(): number;
  23690. set refreshRate(value: number);
  23691. /**
  23692. * Adds a post process to the render target rendering passes.
  23693. * @param postProcess define the post process to add
  23694. */
  23695. addPostProcess(postProcess: PostProcess): void;
  23696. /**
  23697. * Clear all the post processes attached to the render target
  23698. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23699. */
  23700. clearPostProcesses(dispose?: boolean): void;
  23701. /**
  23702. * Remove one of the post process from the list of attached post processes to the texture
  23703. * @param postProcess define the post process to remove from the list
  23704. */
  23705. removePostProcess(postProcess: PostProcess): void;
  23706. /** @hidden */
  23707. _shouldRender(): boolean;
  23708. /**
  23709. * Gets the actual render size of the texture.
  23710. * @returns the width of the render size
  23711. */
  23712. getRenderSize(): number;
  23713. /**
  23714. * Gets the actual render width of the texture.
  23715. * @returns the width of the render size
  23716. */
  23717. getRenderWidth(): number;
  23718. /**
  23719. * Gets the actual render height of the texture.
  23720. * @returns the height of the render size
  23721. */
  23722. getRenderHeight(): number;
  23723. /**
  23724. * Gets the actual number of layers of the texture.
  23725. * @returns the number of layers
  23726. */
  23727. getRenderLayers(): number;
  23728. /**
  23729. * Get if the texture can be rescaled or not.
  23730. */
  23731. get canRescale(): boolean;
  23732. /**
  23733. * Resize the texture using a ratio.
  23734. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23735. */
  23736. scale(ratio: number): void;
  23737. /**
  23738. * Get the texture reflection matrix used to rotate/transform the reflection.
  23739. * @returns the reflection matrix
  23740. */
  23741. getReflectionTextureMatrix(): Matrix;
  23742. /**
  23743. * Resize the texture to a new desired size.
  23744. * Be carrefull as it will recreate all the data in the new texture.
  23745. * @param size Define the new size. It can be:
  23746. * - a number for squared texture,
  23747. * - an object containing { width: number, height: number }
  23748. * - or an object containing a ratio { ratio: number }
  23749. */
  23750. resize(size: number | {
  23751. width: number;
  23752. height: number;
  23753. } | {
  23754. ratio: number;
  23755. }): void;
  23756. private _defaultRenderListPrepared;
  23757. /**
  23758. * Renders all the objects from the render list into the texture.
  23759. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23760. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23761. */
  23762. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23763. private _bestReflectionRenderTargetDimension;
  23764. private _prepareRenderingManager;
  23765. /**
  23766. * @hidden
  23767. * @param faceIndex face index to bind to if this is a cubetexture
  23768. * @param layer defines the index of the texture to bind in the array
  23769. */
  23770. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23771. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23772. private renderToTarget;
  23773. /**
  23774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23775. * This allowed control for front to back rendering or reversly depending of the special needs.
  23776. *
  23777. * @param renderingGroupId The rendering group id corresponding to its index
  23778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23781. */
  23782. 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;
  23783. /**
  23784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23785. *
  23786. * @param renderingGroupId The rendering group id corresponding to its index
  23787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23788. */
  23789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23790. /**
  23791. * Clones the texture.
  23792. * @returns the cloned texture
  23793. */
  23794. clone(): RenderTargetTexture;
  23795. /**
  23796. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23797. * @returns The JSON representation of the texture
  23798. */
  23799. serialize(): any;
  23800. /**
  23801. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23802. */
  23803. disposeFramebufferObjects(): void;
  23804. /**
  23805. * Dispose the texture and release its associated resources.
  23806. */
  23807. dispose(): void;
  23808. /** @hidden */
  23809. _rebuild(): void;
  23810. /**
  23811. * Clear the info related to rendering groups preventing retention point in material dispose.
  23812. */
  23813. freeRenderingGroups(): void;
  23814. /**
  23815. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23816. * @returns the view count
  23817. */
  23818. getViewCount(): number;
  23819. }
  23820. }
  23821. declare module BABYLON {
  23822. /**
  23823. * Class used to manipulate GUIDs
  23824. */
  23825. export class GUID {
  23826. /**
  23827. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23828. * Be aware Math.random() could cause collisions, but:
  23829. * "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"
  23830. * @returns a pseudo random id
  23831. */
  23832. static RandomId(): string;
  23833. }
  23834. }
  23835. declare module BABYLON {
  23836. /**
  23837. * Options to be used when creating a shadow depth material
  23838. */
  23839. export interface IIOptionShadowDepthMaterial {
  23840. /** Variables in the vertex shader code that need to have their names remapped.
  23841. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23842. * "var_name" should be either: worldPos or vNormalW
  23843. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23844. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23845. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23846. */
  23847. remappedVariables?: string[];
  23848. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23849. standalone?: boolean;
  23850. }
  23851. /**
  23852. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23853. */
  23854. export class ShadowDepthWrapper {
  23855. private _scene;
  23856. private _options?;
  23857. private _baseMaterial;
  23858. private _onEffectCreatedObserver;
  23859. private _subMeshToEffect;
  23860. private _subMeshToDepthEffect;
  23861. private _meshes;
  23862. /** @hidden */
  23863. _matriceNames: any;
  23864. /** Gets the standalone status of the wrapper */
  23865. get standalone(): boolean;
  23866. /** Gets the base material the wrapper is built upon */
  23867. get baseMaterial(): Material;
  23868. /**
  23869. * Instantiate a new shadow depth wrapper.
  23870. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23871. * generate the shadow depth map. For more information, please refer to the documentation:
  23872. * https://doc.babylonjs.com/babylon101/shadows
  23873. * @param baseMaterial Material to wrap
  23874. * @param scene Define the scene the material belongs to
  23875. * @param options Options used to create the wrapper
  23876. */
  23877. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23878. /**
  23879. * Gets the effect to use to generate the depth map
  23880. * @param subMesh subMesh to get the effect for
  23881. * @param shadowGenerator shadow generator to get the effect for
  23882. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23883. */
  23884. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23885. /**
  23886. * Specifies that the submesh is ready to be used for depth rendering
  23887. * @param subMesh submesh to check
  23888. * @param defines the list of defines to take into account when checking the effect
  23889. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23890. * @param useInstances specifies that instances should be used
  23891. * @returns a boolean indicating that the submesh is ready or not
  23892. */
  23893. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23894. /**
  23895. * Disposes the resources
  23896. */
  23897. dispose(): void;
  23898. private _makeEffect;
  23899. }
  23900. }
  23901. declare module BABYLON {
  23902. interface ThinEngine {
  23903. /**
  23904. * Unbind a list of render target textures from the webGL context
  23905. * This is used only when drawBuffer extension or webGL2 are active
  23906. * @param textures defines the render target textures to unbind
  23907. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23908. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23909. */
  23910. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23911. /**
  23912. * Create a multi render target texture
  23913. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23914. * @param size defines the size of the texture
  23915. * @param options defines the creation options
  23916. * @returns the cube texture as an InternalTexture
  23917. */
  23918. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23919. /**
  23920. * Update the sample count for a given multiple render target texture
  23921. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23922. * @param textures defines the textures to update
  23923. * @param samples defines the sample count to set
  23924. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23925. */
  23926. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23927. /**
  23928. * Select a subsets of attachments to draw to.
  23929. * @param attachments gl attachments
  23930. */
  23931. bindAttachments(attachments: number[]): void;
  23932. }
  23933. }
  23934. declare module BABYLON {
  23935. /**
  23936. * Creation options of the multi render target texture.
  23937. */
  23938. export interface IMultiRenderTargetOptions {
  23939. /**
  23940. * Define if the texture needs to create mip maps after render.
  23941. */
  23942. generateMipMaps?: boolean;
  23943. /**
  23944. * Define the types of all the draw buffers we want to create
  23945. */
  23946. types?: number[];
  23947. /**
  23948. * Define the sampling modes of all the draw buffers we want to create
  23949. */
  23950. samplingModes?: number[];
  23951. /**
  23952. * Define if a depth buffer is required
  23953. */
  23954. generateDepthBuffer?: boolean;
  23955. /**
  23956. * Define if a stencil buffer is required
  23957. */
  23958. generateStencilBuffer?: boolean;
  23959. /**
  23960. * Define if a depth texture is required instead of a depth buffer
  23961. */
  23962. generateDepthTexture?: boolean;
  23963. /**
  23964. * Define the number of desired draw buffers
  23965. */
  23966. textureCount?: number;
  23967. /**
  23968. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23969. */
  23970. doNotChangeAspectRatio?: boolean;
  23971. /**
  23972. * Define the default type of the buffers we are creating
  23973. */
  23974. defaultType?: number;
  23975. }
  23976. /**
  23977. * A multi render target, like a render target provides the ability to render to a texture.
  23978. * Unlike the render target, it can render to several draw buffers in one draw.
  23979. * This is specially interesting in deferred rendering or for any effects requiring more than
  23980. * just one color from a single pass.
  23981. */
  23982. export class MultiRenderTarget extends RenderTargetTexture {
  23983. private _internalTextures;
  23984. private _textures;
  23985. private _multiRenderTargetOptions;
  23986. private _count;
  23987. /**
  23988. * Get if draw buffers are currently supported by the used hardware and browser.
  23989. */
  23990. get isSupported(): boolean;
  23991. /**
  23992. * Get the list of textures generated by the multi render target.
  23993. */
  23994. get textures(): Texture[];
  23995. /**
  23996. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23997. */
  23998. get count(): number;
  23999. /**
  24000. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24001. */
  24002. get depthTexture(): Texture;
  24003. /**
  24004. * Set the wrapping mode on U of all the textures we are rendering to.
  24005. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24006. */
  24007. set wrapU(wrap: number);
  24008. /**
  24009. * Set the wrapping mode on V of all the textures we are rendering to.
  24010. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24011. */
  24012. set wrapV(wrap: number);
  24013. /**
  24014. * Instantiate a new multi render target texture.
  24015. * A multi render target, like a render target provides the ability to render to a texture.
  24016. * Unlike the render target, it can render to several draw buffers in one draw.
  24017. * This is specially interesting in deferred rendering or for any effects requiring more than
  24018. * just one color from a single pass.
  24019. * @param name Define the name of the texture
  24020. * @param size Define the size of the buffers to render to
  24021. * @param count Define the number of target we are rendering into
  24022. * @param scene Define the scene the texture belongs to
  24023. * @param options Define the options used to create the multi render target
  24024. */
  24025. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24026. /** @hidden */
  24027. _rebuild(): void;
  24028. private _createInternalTextures;
  24029. private _createTextures;
  24030. /**
  24031. * Define the number of samples used if MSAA is enabled.
  24032. */
  24033. get samples(): number;
  24034. set samples(value: number);
  24035. /**
  24036. * Resize all the textures in the multi render target.
  24037. * Be carrefull as it will recreate all the data in the new texture.
  24038. * @param size Define the new size
  24039. */
  24040. resize(size: any): void;
  24041. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24042. /**
  24043. * Dispose the render targets and their associated resources
  24044. */
  24045. dispose(): void;
  24046. /**
  24047. * Release all the underlying texture used as draw buffers.
  24048. */
  24049. releaseInternalTextures(): void;
  24050. }
  24051. }
  24052. declare module BABYLON {
  24053. /** @hidden */
  24054. export var imageProcessingPixelShader: {
  24055. name: string;
  24056. shader: string;
  24057. };
  24058. }
  24059. declare module BABYLON {
  24060. /**
  24061. * ImageProcessingPostProcess
  24062. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24063. */
  24064. export class ImageProcessingPostProcess extends PostProcess {
  24065. /**
  24066. * Default configuration related to image processing available in the PBR Material.
  24067. */
  24068. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24069. /**
  24070. * Gets the image processing configuration used either in this material.
  24071. */
  24072. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24073. /**
  24074. * Sets the Default image processing configuration used either in the this material.
  24075. *
  24076. * If sets to null, the scene one is in use.
  24077. */
  24078. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24079. /**
  24080. * Keep track of the image processing observer to allow dispose and replace.
  24081. */
  24082. private _imageProcessingObserver;
  24083. /**
  24084. * Attaches a new image processing configuration to the PBR Material.
  24085. * @param configuration
  24086. */
  24087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24088. /**
  24089. * If the post process is supported.
  24090. */
  24091. get isSupported(): boolean;
  24092. /**
  24093. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24094. */
  24095. get colorCurves(): Nullable<ColorCurves>;
  24096. /**
  24097. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24098. */
  24099. set colorCurves(value: Nullable<ColorCurves>);
  24100. /**
  24101. * Gets wether the color curves effect is enabled.
  24102. */
  24103. get colorCurvesEnabled(): boolean;
  24104. /**
  24105. * Sets wether the color curves effect is enabled.
  24106. */
  24107. set colorCurvesEnabled(value: boolean);
  24108. /**
  24109. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24110. */
  24111. get colorGradingTexture(): Nullable<BaseTexture>;
  24112. /**
  24113. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24114. */
  24115. set colorGradingTexture(value: Nullable<BaseTexture>);
  24116. /**
  24117. * Gets wether the color grading effect is enabled.
  24118. */
  24119. get colorGradingEnabled(): boolean;
  24120. /**
  24121. * Gets wether the color grading effect is enabled.
  24122. */
  24123. set colorGradingEnabled(value: boolean);
  24124. /**
  24125. * Gets exposure used in the effect.
  24126. */
  24127. get exposure(): number;
  24128. /**
  24129. * Sets exposure used in the effect.
  24130. */
  24131. set exposure(value: number);
  24132. /**
  24133. * Gets wether tonemapping is enabled or not.
  24134. */
  24135. get toneMappingEnabled(): boolean;
  24136. /**
  24137. * Sets wether tonemapping is enabled or not
  24138. */
  24139. set toneMappingEnabled(value: boolean);
  24140. /**
  24141. * Gets the type of tone mapping effect.
  24142. */
  24143. get toneMappingType(): number;
  24144. /**
  24145. * Sets the type of tone mapping effect.
  24146. */
  24147. set toneMappingType(value: number);
  24148. /**
  24149. * Gets contrast used in the effect.
  24150. */
  24151. get contrast(): number;
  24152. /**
  24153. * Sets contrast used in the effect.
  24154. */
  24155. set contrast(value: number);
  24156. /**
  24157. * Gets Vignette stretch size.
  24158. */
  24159. get vignetteStretch(): number;
  24160. /**
  24161. * Sets Vignette stretch size.
  24162. */
  24163. set vignetteStretch(value: number);
  24164. /**
  24165. * Gets Vignette centre X Offset.
  24166. */
  24167. get vignetteCentreX(): number;
  24168. /**
  24169. * Sets Vignette centre X Offset.
  24170. */
  24171. set vignetteCentreX(value: number);
  24172. /**
  24173. * Gets Vignette centre Y Offset.
  24174. */
  24175. get vignetteCentreY(): number;
  24176. /**
  24177. * Sets Vignette centre Y Offset.
  24178. */
  24179. set vignetteCentreY(value: number);
  24180. /**
  24181. * Gets Vignette weight or intensity of the vignette effect.
  24182. */
  24183. get vignetteWeight(): number;
  24184. /**
  24185. * Sets Vignette weight or intensity of the vignette effect.
  24186. */
  24187. set vignetteWeight(value: number);
  24188. /**
  24189. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24190. * if vignetteEnabled is set to true.
  24191. */
  24192. get vignetteColor(): Color4;
  24193. /**
  24194. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24195. * if vignetteEnabled is set to true.
  24196. */
  24197. set vignetteColor(value: Color4);
  24198. /**
  24199. * Gets Camera field of view used by the Vignette effect.
  24200. */
  24201. get vignetteCameraFov(): number;
  24202. /**
  24203. * Sets Camera field of view used by the Vignette effect.
  24204. */
  24205. set vignetteCameraFov(value: number);
  24206. /**
  24207. * Gets the vignette blend mode allowing different kind of effect.
  24208. */
  24209. get vignetteBlendMode(): number;
  24210. /**
  24211. * Sets the vignette blend mode allowing different kind of effect.
  24212. */
  24213. set vignetteBlendMode(value: number);
  24214. /**
  24215. * Gets wether the vignette effect is enabled.
  24216. */
  24217. get vignetteEnabled(): boolean;
  24218. /**
  24219. * Sets wether the vignette effect is enabled.
  24220. */
  24221. set vignetteEnabled(value: boolean);
  24222. private _fromLinearSpace;
  24223. /**
  24224. * Gets wether the input of the processing is in Gamma or Linear Space.
  24225. */
  24226. get fromLinearSpace(): boolean;
  24227. /**
  24228. * Sets wether the input of the processing is in Gamma or Linear Space.
  24229. */
  24230. set fromLinearSpace(value: boolean);
  24231. /**
  24232. * Defines cache preventing GC.
  24233. */
  24234. private _defines;
  24235. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24236. /**
  24237. * "ImageProcessingPostProcess"
  24238. * @returns "ImageProcessingPostProcess"
  24239. */
  24240. getClassName(): string;
  24241. /**
  24242. * @hidden
  24243. */
  24244. _updateParameters(): void;
  24245. dispose(camera?: Camera): void;
  24246. }
  24247. }
  24248. declare module BABYLON {
  24249. /** @hidden */
  24250. export var fibonacci: {
  24251. name: string;
  24252. shader: string;
  24253. };
  24254. }
  24255. declare module BABYLON {
  24256. /** @hidden */
  24257. export var subSurfaceScatteringFunctions: {
  24258. name: string;
  24259. shader: string;
  24260. };
  24261. }
  24262. declare module BABYLON {
  24263. /** @hidden */
  24264. export var diffusionProfile: {
  24265. name: string;
  24266. shader: string;
  24267. };
  24268. }
  24269. declare module BABYLON {
  24270. /** @hidden */
  24271. export var subSurfaceScatteringPixelShader: {
  24272. name: string;
  24273. shader: string;
  24274. };
  24275. }
  24276. declare module BABYLON {
  24277. /**
  24278. * Sub surface scattering post process
  24279. */
  24280. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24281. /**
  24282. * Gets a string identifying the name of the class
  24283. * @returns "SubSurfaceScatteringPostProcess" string
  24284. */
  24285. getClassName(): string;
  24286. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24287. }
  24288. }
  24289. declare module BABYLON {
  24290. /**
  24291. * Interface for defining prepass effects in the prepass post-process pipeline
  24292. */
  24293. export interface PrePassEffectConfiguration {
  24294. /**
  24295. * Post process to attach for this effect
  24296. */
  24297. postProcess: PostProcess;
  24298. /**
  24299. * Is the effect enabled
  24300. */
  24301. enabled: boolean;
  24302. /**
  24303. * Disposes the effect configuration
  24304. */
  24305. dispose(): void;
  24306. /**
  24307. * Disposes the effect configuration
  24308. */
  24309. createPostProcess: () => PostProcess;
  24310. }
  24311. }
  24312. declare module BABYLON {
  24313. /**
  24314. * Contains all parameters needed for the prepass to perform
  24315. * screen space subsurface scattering
  24316. */
  24317. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24318. private _ssDiffusionS;
  24319. private _ssFilterRadii;
  24320. private _ssDiffusionD;
  24321. /**
  24322. * Post process to attach for screen space subsurface scattering
  24323. */
  24324. postProcess: SubSurfaceScatteringPostProcess;
  24325. /**
  24326. * Diffusion profile color for subsurface scattering
  24327. */
  24328. get ssDiffusionS(): number[];
  24329. /**
  24330. * Diffusion profile max color channel value for subsurface scattering
  24331. */
  24332. get ssDiffusionD(): number[];
  24333. /**
  24334. * Diffusion profile filter radius for subsurface scattering
  24335. */
  24336. get ssFilterRadii(): number[];
  24337. /**
  24338. * Is subsurface enabled
  24339. */
  24340. enabled: boolean;
  24341. /**
  24342. * Diffusion profile colors for subsurface scattering
  24343. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24344. * See ...
  24345. * Note that you can only store up to 5 of them
  24346. */
  24347. ssDiffusionProfileColors: Color3[];
  24348. /**
  24349. * Defines the ratio real world => scene units.
  24350. * Used for subsurface scattering
  24351. */
  24352. metersPerUnit: number;
  24353. private _scene;
  24354. /**
  24355. * Builds a subsurface configuration object
  24356. * @param scene The scene
  24357. */
  24358. constructor(scene: Scene);
  24359. /**
  24360. * Adds a new diffusion profile.
  24361. * Useful for more realistic subsurface scattering on diverse materials.
  24362. * @param color The color of the diffusion profile. Should be the average color of the material.
  24363. * @return The index of the diffusion profile for the material subsurface configuration
  24364. */
  24365. addDiffusionProfile(color: Color3): number;
  24366. /**
  24367. * Creates the sss post process
  24368. * @return The created post process
  24369. */
  24370. createPostProcess(): SubSurfaceScatteringPostProcess;
  24371. /**
  24372. * Deletes all diffusion profiles.
  24373. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24374. */
  24375. clearAllDiffusionProfiles(): void;
  24376. /**
  24377. * Disposes this object
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * @hidden
  24382. * https://zero-radiance.github.io/post/sampling-diffusion/
  24383. *
  24384. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24385. * ------------------------------------------------------------------------------------
  24386. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24387. * PDF[r, phi, s] = r * R[r, phi, s]
  24388. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24389. * ------------------------------------------------------------------------------------
  24390. * We importance sample the color channel with the widest scattering distance.
  24391. */
  24392. getDiffusionProfileParameters(color: Color3): number;
  24393. /**
  24394. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24395. * 'u' is the random number (the value of the CDF): [0, 1).
  24396. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24397. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24398. */
  24399. private _sampleBurleyDiffusionProfile;
  24400. }
  24401. }
  24402. declare module BABYLON {
  24403. /**
  24404. * Renders a pre pass of the scene
  24405. * This means every mesh in the scene will be rendered to a render target texture
  24406. * And then this texture will be composited to the rendering canvas with post processes
  24407. * It is necessary for effects like subsurface scattering or deferred shading
  24408. */
  24409. export class PrePassRenderer {
  24410. /** @hidden */
  24411. static _SceneComponentInitialization: (scene: Scene) => void;
  24412. private _scene;
  24413. private _engine;
  24414. private _isDirty;
  24415. /**
  24416. * Number of textures in the multi render target texture where the scene is directly rendered
  24417. */
  24418. readonly mrtCount: number;
  24419. /**
  24420. * The render target where the scene is directly rendered
  24421. */
  24422. prePassRT: MultiRenderTarget;
  24423. private _mrtTypes;
  24424. private _multiRenderAttachments;
  24425. private _defaultAttachments;
  24426. private _clearAttachments;
  24427. private _postProcesses;
  24428. private readonly _clearColor;
  24429. /**
  24430. * Image processing post process for composition
  24431. */
  24432. imageProcessingPostProcess: ImageProcessingPostProcess;
  24433. /**
  24434. * Configuration for sub surface scattering post process
  24435. */
  24436. subSurfaceConfiguration: SubSurfaceConfiguration;
  24437. /**
  24438. * Should materials render their geometry on the MRT
  24439. */
  24440. materialsShouldRenderGeometry: boolean;
  24441. /**
  24442. * Should materials render the irradiance information on the MRT
  24443. */
  24444. materialsShouldRenderIrradiance: boolean;
  24445. private _enabled;
  24446. /**
  24447. * Indicates if the prepass is enabled
  24448. */
  24449. get enabled(): boolean;
  24450. /**
  24451. * How many samples are used for MSAA of the scene render target
  24452. */
  24453. get samples(): number;
  24454. set samples(n: number);
  24455. /**
  24456. * Instanciates a prepass renderer
  24457. * @param scene The scene
  24458. */
  24459. constructor(scene: Scene);
  24460. private _initializeAttachments;
  24461. private _createCompositionEffect;
  24462. /**
  24463. * Indicates if rendering a prepass is supported
  24464. */
  24465. get isSupported(): boolean;
  24466. /**
  24467. * Sets the proper output textures to draw in the engine.
  24468. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24469. */
  24470. bindAttachmentsForEffect(effect: Effect): void;
  24471. /**
  24472. * @hidden
  24473. */
  24474. _beforeCameraDraw(): void;
  24475. /**
  24476. * @hidden
  24477. */
  24478. _afterCameraDraw(): void;
  24479. private _checkRTSize;
  24480. private _bindFrameBuffer;
  24481. /**
  24482. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24483. */
  24484. clear(): void;
  24485. private _setState;
  24486. private _enable;
  24487. private _disable;
  24488. private _resetPostProcessChain;
  24489. private _bindPostProcessChain;
  24490. /**
  24491. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24492. */
  24493. markAsDirty(): void;
  24494. private _update;
  24495. /**
  24496. * Disposes the prepass renderer.
  24497. */
  24498. dispose(): void;
  24499. }
  24500. }
  24501. declare module BABYLON {
  24502. /**
  24503. * Options for compiling materials.
  24504. */
  24505. export interface IMaterialCompilationOptions {
  24506. /**
  24507. * Defines whether clip planes are enabled.
  24508. */
  24509. clipPlane: boolean;
  24510. /**
  24511. * Defines whether instances are enabled.
  24512. */
  24513. useInstances: boolean;
  24514. }
  24515. /**
  24516. * Options passed when calling customShaderNameResolve
  24517. */
  24518. export interface ICustomShaderNameResolveOptions {
  24519. /**
  24520. * 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
  24521. */
  24522. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24523. }
  24524. /**
  24525. * Base class for the main features of a material in Babylon.js
  24526. */
  24527. export class Material implements IAnimatable {
  24528. /**
  24529. * Returns the triangle fill mode
  24530. */
  24531. static readonly TriangleFillMode: number;
  24532. /**
  24533. * Returns the wireframe mode
  24534. */
  24535. static readonly WireFrameFillMode: number;
  24536. /**
  24537. * Returns the point fill mode
  24538. */
  24539. static readonly PointFillMode: number;
  24540. /**
  24541. * Returns the point list draw mode
  24542. */
  24543. static readonly PointListDrawMode: number;
  24544. /**
  24545. * Returns the line list draw mode
  24546. */
  24547. static readonly LineListDrawMode: number;
  24548. /**
  24549. * Returns the line loop draw mode
  24550. */
  24551. static readonly LineLoopDrawMode: number;
  24552. /**
  24553. * Returns the line strip draw mode
  24554. */
  24555. static readonly LineStripDrawMode: number;
  24556. /**
  24557. * Returns the triangle strip draw mode
  24558. */
  24559. static readonly TriangleStripDrawMode: number;
  24560. /**
  24561. * Returns the triangle fan draw mode
  24562. */
  24563. static readonly TriangleFanDrawMode: number;
  24564. /**
  24565. * Stores the clock-wise side orientation
  24566. */
  24567. static readonly ClockWiseSideOrientation: number;
  24568. /**
  24569. * Stores the counter clock-wise side orientation
  24570. */
  24571. static readonly CounterClockWiseSideOrientation: number;
  24572. /**
  24573. * The dirty texture flag value
  24574. */
  24575. static readonly TextureDirtyFlag: number;
  24576. /**
  24577. * The dirty light flag value
  24578. */
  24579. static readonly LightDirtyFlag: number;
  24580. /**
  24581. * The dirty fresnel flag value
  24582. */
  24583. static readonly FresnelDirtyFlag: number;
  24584. /**
  24585. * The dirty attribute flag value
  24586. */
  24587. static readonly AttributesDirtyFlag: number;
  24588. /**
  24589. * The dirty misc flag value
  24590. */
  24591. static readonly MiscDirtyFlag: number;
  24592. /**
  24593. * The all dirty flag value
  24594. */
  24595. static readonly AllDirtyFlag: number;
  24596. /**
  24597. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24598. */
  24599. static readonly MATERIAL_OPAQUE: number;
  24600. /**
  24601. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24602. */
  24603. static readonly MATERIAL_ALPHATEST: number;
  24604. /**
  24605. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24606. */
  24607. static readonly MATERIAL_ALPHABLEND: number;
  24608. /**
  24609. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24610. * They are also discarded below the alpha cutoff threshold to improve performances.
  24611. */
  24612. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24613. /**
  24614. * The Whiteout method is used to blend normals.
  24615. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24616. */
  24617. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24618. /**
  24619. * The Reoriented Normal Mapping method is used to blend normals.
  24620. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24621. */
  24622. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24623. /**
  24624. * Custom callback helping to override the default shader used in the material.
  24625. */
  24626. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24627. /**
  24628. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24629. */
  24630. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24631. /**
  24632. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24633. * This means that the material can keep using a previous shader while a new one is being compiled.
  24634. * This is mostly used when shader parallel compilation is supported (true by default)
  24635. */
  24636. allowShaderHotSwapping: boolean;
  24637. /**
  24638. * The ID of the material
  24639. */
  24640. id: string;
  24641. /**
  24642. * Gets or sets the unique id of the material
  24643. */
  24644. uniqueId: number;
  24645. /**
  24646. * The name of the material
  24647. */
  24648. name: string;
  24649. /**
  24650. * Gets or sets user defined metadata
  24651. */
  24652. metadata: any;
  24653. /**
  24654. * For internal use only. Please do not use.
  24655. */
  24656. reservedDataStore: any;
  24657. /**
  24658. * Specifies if the ready state should be checked on each call
  24659. */
  24660. checkReadyOnEveryCall: boolean;
  24661. /**
  24662. * Specifies if the ready state should be checked once
  24663. */
  24664. checkReadyOnlyOnce: boolean;
  24665. /**
  24666. * The state of the material
  24667. */
  24668. state: string;
  24669. /**
  24670. * If the material can be rendered to several textures with MRT extension
  24671. */
  24672. get canRenderToMRT(): boolean;
  24673. /**
  24674. * The alpha value of the material
  24675. */
  24676. protected _alpha: number;
  24677. /**
  24678. * List of inspectable custom properties (used by the Inspector)
  24679. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24680. */
  24681. inspectableCustomProperties: IInspectable[];
  24682. /**
  24683. * Sets the alpha value of the material
  24684. */
  24685. set alpha(value: number);
  24686. /**
  24687. * Gets the alpha value of the material
  24688. */
  24689. get alpha(): number;
  24690. /**
  24691. * Specifies if back face culling is enabled
  24692. */
  24693. protected _backFaceCulling: boolean;
  24694. /**
  24695. * Sets the back-face culling state
  24696. */
  24697. set backFaceCulling(value: boolean);
  24698. /**
  24699. * Gets the back-face culling state
  24700. */
  24701. get backFaceCulling(): boolean;
  24702. /**
  24703. * Stores the value for side orientation
  24704. */
  24705. sideOrientation: number;
  24706. /**
  24707. * Callback triggered when the material is compiled
  24708. */
  24709. onCompiled: Nullable<(effect: Effect) => void>;
  24710. /**
  24711. * Callback triggered when an error occurs
  24712. */
  24713. onError: Nullable<(effect: Effect, errors: string) => void>;
  24714. /**
  24715. * Callback triggered to get the render target textures
  24716. */
  24717. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24718. /**
  24719. * Gets a boolean indicating that current material needs to register RTT
  24720. */
  24721. get hasRenderTargetTextures(): boolean;
  24722. /**
  24723. * Specifies if the material should be serialized
  24724. */
  24725. doNotSerialize: boolean;
  24726. /**
  24727. * @hidden
  24728. */
  24729. _storeEffectOnSubMeshes: boolean;
  24730. /**
  24731. * Stores the animations for the material
  24732. */
  24733. animations: Nullable<Array<Animation>>;
  24734. /**
  24735. * An event triggered when the material is disposed
  24736. */
  24737. onDisposeObservable: Observable<Material>;
  24738. /**
  24739. * An observer which watches for dispose events
  24740. */
  24741. private _onDisposeObserver;
  24742. private _onUnBindObservable;
  24743. /**
  24744. * Called during a dispose event
  24745. */
  24746. set onDispose(callback: () => void);
  24747. private _onBindObservable;
  24748. /**
  24749. * An event triggered when the material is bound
  24750. */
  24751. get onBindObservable(): Observable<AbstractMesh>;
  24752. /**
  24753. * An observer which watches for bind events
  24754. */
  24755. private _onBindObserver;
  24756. /**
  24757. * Called during a bind event
  24758. */
  24759. set onBind(callback: (Mesh: AbstractMesh) => void);
  24760. /**
  24761. * An event triggered when the material is unbound
  24762. */
  24763. get onUnBindObservable(): Observable<Material>;
  24764. protected _onEffectCreatedObservable: Nullable<Observable<{
  24765. effect: Effect;
  24766. subMesh: Nullable<SubMesh>;
  24767. }>>;
  24768. /**
  24769. * An event triggered when the effect is (re)created
  24770. */
  24771. get onEffectCreatedObservable(): Observable<{
  24772. effect: Effect;
  24773. subMesh: Nullable<SubMesh>;
  24774. }>;
  24775. /**
  24776. * Stores the value of the alpha mode
  24777. */
  24778. private _alphaMode;
  24779. /**
  24780. * Sets the value of the alpha mode.
  24781. *
  24782. * | Value | Type | Description |
  24783. * | --- | --- | --- |
  24784. * | 0 | ALPHA_DISABLE | |
  24785. * | 1 | ALPHA_ADD | |
  24786. * | 2 | ALPHA_COMBINE | |
  24787. * | 3 | ALPHA_SUBTRACT | |
  24788. * | 4 | ALPHA_MULTIPLY | |
  24789. * | 5 | ALPHA_MAXIMIZED | |
  24790. * | 6 | ALPHA_ONEONE | |
  24791. * | 7 | ALPHA_PREMULTIPLIED | |
  24792. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24793. * | 9 | ALPHA_INTERPOLATE | |
  24794. * | 10 | ALPHA_SCREENMODE | |
  24795. *
  24796. */
  24797. set alphaMode(value: number);
  24798. /**
  24799. * Gets the value of the alpha mode
  24800. */
  24801. get alphaMode(): number;
  24802. /**
  24803. * Stores the state of the need depth pre-pass value
  24804. */
  24805. private _needDepthPrePass;
  24806. /**
  24807. * Sets the need depth pre-pass value
  24808. */
  24809. set needDepthPrePass(value: boolean);
  24810. /**
  24811. * Gets the depth pre-pass value
  24812. */
  24813. get needDepthPrePass(): boolean;
  24814. /**
  24815. * Specifies if depth writing should be disabled
  24816. */
  24817. disableDepthWrite: boolean;
  24818. /**
  24819. * Specifies if color writing should be disabled
  24820. */
  24821. disableColorWrite: boolean;
  24822. /**
  24823. * Specifies if depth writing should be forced
  24824. */
  24825. forceDepthWrite: boolean;
  24826. /**
  24827. * Specifies the depth function that should be used. 0 means the default engine function
  24828. */
  24829. depthFunction: number;
  24830. /**
  24831. * Specifies if there should be a separate pass for culling
  24832. */
  24833. separateCullingPass: boolean;
  24834. /**
  24835. * Stores the state specifing if fog should be enabled
  24836. */
  24837. private _fogEnabled;
  24838. /**
  24839. * Sets the state for enabling fog
  24840. */
  24841. set fogEnabled(value: boolean);
  24842. /**
  24843. * Gets the value of the fog enabled state
  24844. */
  24845. get fogEnabled(): boolean;
  24846. /**
  24847. * Stores the size of points
  24848. */
  24849. pointSize: number;
  24850. /**
  24851. * Stores the z offset value
  24852. */
  24853. zOffset: number;
  24854. get wireframe(): boolean;
  24855. /**
  24856. * Sets the state of wireframe mode
  24857. */
  24858. set wireframe(value: boolean);
  24859. /**
  24860. * Gets the value specifying if point clouds are enabled
  24861. */
  24862. get pointsCloud(): boolean;
  24863. /**
  24864. * Sets the state of point cloud mode
  24865. */
  24866. set pointsCloud(value: boolean);
  24867. /**
  24868. * Gets the material fill mode
  24869. */
  24870. get fillMode(): number;
  24871. /**
  24872. * Sets the material fill mode
  24873. */
  24874. set fillMode(value: number);
  24875. /**
  24876. * @hidden
  24877. * Stores the effects for the material
  24878. */
  24879. _effect: Nullable<Effect>;
  24880. /**
  24881. * Specifies if uniform buffers should be used
  24882. */
  24883. private _useUBO;
  24884. /**
  24885. * Stores a reference to the scene
  24886. */
  24887. private _scene;
  24888. /**
  24889. * Stores the fill mode state
  24890. */
  24891. private _fillMode;
  24892. /**
  24893. * Specifies if the depth write state should be cached
  24894. */
  24895. private _cachedDepthWriteState;
  24896. /**
  24897. * Specifies if the color write state should be cached
  24898. */
  24899. private _cachedColorWriteState;
  24900. /**
  24901. * Specifies if the depth function state should be cached
  24902. */
  24903. private _cachedDepthFunctionState;
  24904. /**
  24905. * Stores the uniform buffer
  24906. */
  24907. protected _uniformBuffer: UniformBuffer;
  24908. /** @hidden */
  24909. _indexInSceneMaterialArray: number;
  24910. /** @hidden */
  24911. meshMap: Nullable<{
  24912. [id: string]: AbstractMesh | undefined;
  24913. }>;
  24914. /**
  24915. * Creates a material instance
  24916. * @param name defines the name of the material
  24917. * @param scene defines the scene to reference
  24918. * @param doNotAdd specifies if the material should be added to the scene
  24919. */
  24920. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24921. /**
  24922. * Returns a string representation of the current material
  24923. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24924. * @returns a string with material information
  24925. */
  24926. toString(fullDetails?: boolean): string;
  24927. /**
  24928. * Gets the class name of the material
  24929. * @returns a string with the class name of the material
  24930. */
  24931. getClassName(): string;
  24932. /**
  24933. * Specifies if updates for the material been locked
  24934. */
  24935. get isFrozen(): boolean;
  24936. /**
  24937. * Locks updates for the material
  24938. */
  24939. freeze(): void;
  24940. /**
  24941. * Unlocks updates for the material
  24942. */
  24943. unfreeze(): void;
  24944. /**
  24945. * Specifies if the material is ready to be used
  24946. * @param mesh defines the mesh to check
  24947. * @param useInstances specifies if instances should be used
  24948. * @returns a boolean indicating if the material is ready to be used
  24949. */
  24950. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24951. /**
  24952. * Specifies that the submesh is ready to be used
  24953. * @param mesh defines the mesh to check
  24954. * @param subMesh defines which submesh to check
  24955. * @param useInstances specifies that instances should be used
  24956. * @returns a boolean indicating that the submesh is ready or not
  24957. */
  24958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24959. /**
  24960. * Returns the material effect
  24961. * @returns the effect associated with the material
  24962. */
  24963. getEffect(): Nullable<Effect>;
  24964. /**
  24965. * Returns the current scene
  24966. * @returns a Scene
  24967. */
  24968. getScene(): Scene;
  24969. /**
  24970. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24971. */
  24972. protected _forceAlphaTest: boolean;
  24973. /**
  24974. * The transparency mode of the material.
  24975. */
  24976. protected _transparencyMode: Nullable<number>;
  24977. /**
  24978. * Gets the current transparency mode.
  24979. */
  24980. get transparencyMode(): Nullable<number>;
  24981. /**
  24982. * Sets the transparency mode of the material.
  24983. *
  24984. * | Value | Type | Description |
  24985. * | ----- | ----------------------------------- | ----------- |
  24986. * | 0 | OPAQUE | |
  24987. * | 1 | ALPHATEST | |
  24988. * | 2 | ALPHABLEND | |
  24989. * | 3 | ALPHATESTANDBLEND | |
  24990. *
  24991. */
  24992. set transparencyMode(value: Nullable<number>);
  24993. /**
  24994. * Returns true if alpha blending should be disabled.
  24995. */
  24996. protected get _disableAlphaBlending(): boolean;
  24997. /**
  24998. * Specifies whether or not this material should be rendered in alpha blend mode.
  24999. * @returns a boolean specifying if alpha blending is needed
  25000. */
  25001. needAlphaBlending(): boolean;
  25002. /**
  25003. * Specifies if the mesh will require alpha blending
  25004. * @param mesh defines the mesh to check
  25005. * @returns a boolean specifying if alpha blending is needed for the mesh
  25006. */
  25007. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25008. /**
  25009. * Specifies whether or not this material should be rendered in alpha test mode.
  25010. * @returns a boolean specifying if an alpha test is needed.
  25011. */
  25012. needAlphaTesting(): boolean;
  25013. /**
  25014. * Specifies if material alpha testing should be turned on for the mesh
  25015. * @param mesh defines the mesh to check
  25016. */
  25017. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25018. /**
  25019. * Gets the texture used for the alpha test
  25020. * @returns the texture to use for alpha testing
  25021. */
  25022. getAlphaTestTexture(): Nullable<BaseTexture>;
  25023. /**
  25024. * Marks the material to indicate that it needs to be re-calculated
  25025. */
  25026. markDirty(): void;
  25027. /** @hidden */
  25028. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25029. /**
  25030. * Binds the material to the mesh
  25031. * @param world defines the world transformation matrix
  25032. * @param mesh defines the mesh to bind the material to
  25033. */
  25034. bind(world: Matrix, mesh?: Mesh): void;
  25035. /**
  25036. * Binds the submesh to the material
  25037. * @param world defines the world transformation matrix
  25038. * @param mesh defines the mesh containing the submesh
  25039. * @param subMesh defines the submesh to bind the material to
  25040. */
  25041. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25042. /**
  25043. * Binds the world matrix to the material
  25044. * @param world defines the world transformation matrix
  25045. */
  25046. bindOnlyWorldMatrix(world: Matrix): void;
  25047. /**
  25048. * Binds the scene's uniform buffer to the effect.
  25049. * @param effect defines the effect to bind to the scene uniform buffer
  25050. * @param sceneUbo defines the uniform buffer storing scene data
  25051. */
  25052. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25053. /**
  25054. * Binds the view matrix to the effect
  25055. * @param effect defines the effect to bind the view matrix to
  25056. */
  25057. bindView(effect: Effect): void;
  25058. /**
  25059. * Binds the view projection matrix to the effect
  25060. * @param effect defines the effect to bind the view projection matrix to
  25061. */
  25062. bindViewProjection(effect: Effect): void;
  25063. /**
  25064. * Processes to execute after binding the material to a mesh
  25065. * @param mesh defines the rendered mesh
  25066. */
  25067. protected _afterBind(mesh?: Mesh): void;
  25068. /**
  25069. * Unbinds the material from the mesh
  25070. */
  25071. unbind(): void;
  25072. /**
  25073. * Gets the active textures from the material
  25074. * @returns an array of textures
  25075. */
  25076. getActiveTextures(): BaseTexture[];
  25077. /**
  25078. * Specifies if the material uses a texture
  25079. * @param texture defines the texture to check against the material
  25080. * @returns a boolean specifying if the material uses the texture
  25081. */
  25082. hasTexture(texture: BaseTexture): boolean;
  25083. /**
  25084. * Makes a duplicate of the material, and gives it a new name
  25085. * @param name defines the new name for the duplicated material
  25086. * @returns the cloned material
  25087. */
  25088. clone(name: string): Nullable<Material>;
  25089. /**
  25090. * Gets the meshes bound to the material
  25091. * @returns an array of meshes bound to the material
  25092. */
  25093. getBindedMeshes(): AbstractMesh[];
  25094. /**
  25095. * Force shader compilation
  25096. * @param mesh defines the mesh associated with this material
  25097. * @param onCompiled defines a function to execute once the material is compiled
  25098. * @param options defines the options to configure the compilation
  25099. * @param onError defines a function to execute if the material fails compiling
  25100. */
  25101. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25102. /**
  25103. * Force shader compilation
  25104. * @param mesh defines the mesh that will use this material
  25105. * @param options defines additional options for compiling the shaders
  25106. * @returns a promise that resolves when the compilation completes
  25107. */
  25108. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25109. private static readonly _AllDirtyCallBack;
  25110. private static readonly _ImageProcessingDirtyCallBack;
  25111. private static readonly _TextureDirtyCallBack;
  25112. private static readonly _FresnelDirtyCallBack;
  25113. private static readonly _MiscDirtyCallBack;
  25114. private static readonly _LightsDirtyCallBack;
  25115. private static readonly _AttributeDirtyCallBack;
  25116. private static _FresnelAndMiscDirtyCallBack;
  25117. private static _TextureAndMiscDirtyCallBack;
  25118. private static readonly _DirtyCallbackArray;
  25119. private static readonly _RunDirtyCallBacks;
  25120. /**
  25121. * Marks a define in the material to indicate that it needs to be re-computed
  25122. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25123. */
  25124. markAsDirty(flag: number): void;
  25125. /**
  25126. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25127. * @param func defines a function which checks material defines against the submeshes
  25128. */
  25129. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25130. /**
  25131. * Indicates that the scene should check if the rendering now needs a prepass
  25132. */
  25133. protected _markScenePrePassDirty(): void;
  25134. /**
  25135. * Indicates that we need to re-calculated for all submeshes
  25136. */
  25137. protected _markAllSubMeshesAsAllDirty(): void;
  25138. /**
  25139. * Indicates that image processing needs to be re-calculated for all submeshes
  25140. */
  25141. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25142. /**
  25143. * Indicates that textures need to be re-calculated for all submeshes
  25144. */
  25145. protected _markAllSubMeshesAsTexturesDirty(): void;
  25146. /**
  25147. * Indicates that fresnel needs to be re-calculated for all submeshes
  25148. */
  25149. protected _markAllSubMeshesAsFresnelDirty(): void;
  25150. /**
  25151. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25152. */
  25153. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25154. /**
  25155. * Indicates that lights need to be re-calculated for all submeshes
  25156. */
  25157. protected _markAllSubMeshesAsLightsDirty(): void;
  25158. /**
  25159. * Indicates that attributes need to be re-calculated for all submeshes
  25160. */
  25161. protected _markAllSubMeshesAsAttributesDirty(): void;
  25162. /**
  25163. * Indicates that misc needs to be re-calculated for all submeshes
  25164. */
  25165. protected _markAllSubMeshesAsMiscDirty(): void;
  25166. /**
  25167. * Indicates that textures and misc need to be re-calculated for all submeshes
  25168. */
  25169. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25170. /**
  25171. * Sets the required values to the prepass renderer.
  25172. * @param prePassRenderer defines the prepass renderer to setup.
  25173. * @returns true if the pre pass is needed.
  25174. */
  25175. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25176. /**
  25177. * Disposes the material
  25178. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25179. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25180. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25181. */
  25182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25183. /** @hidden */
  25184. private releaseVertexArrayObject;
  25185. /**
  25186. * Serializes this material
  25187. * @returns the serialized material object
  25188. */
  25189. serialize(): any;
  25190. /**
  25191. * Creates a material from parsed material data
  25192. * @param parsedMaterial defines parsed material data
  25193. * @param scene defines the hosting scene
  25194. * @param rootUrl defines the root URL to use to load textures
  25195. * @returns a new material
  25196. */
  25197. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25198. }
  25199. }
  25200. declare module BABYLON {
  25201. /**
  25202. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25203. * separate meshes. This can be use to improve performances.
  25204. * @see https://doc.babylonjs.com/how_to/multi_materials
  25205. */
  25206. export class MultiMaterial extends Material {
  25207. private _subMaterials;
  25208. /**
  25209. * Gets or Sets the list of Materials used within the multi material.
  25210. * They need to be ordered according to the submeshes order in the associated mesh
  25211. */
  25212. get subMaterials(): Nullable<Material>[];
  25213. set subMaterials(value: Nullable<Material>[]);
  25214. /**
  25215. * Function used to align with Node.getChildren()
  25216. * @returns the list of Materials used within the multi material
  25217. */
  25218. getChildren(): Nullable<Material>[];
  25219. /**
  25220. * Instantiates a new Multi Material
  25221. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25222. * separate meshes. This can be use to improve performances.
  25223. * @see https://doc.babylonjs.com/how_to/multi_materials
  25224. * @param name Define the name in the scene
  25225. * @param scene Define the scene the material belongs to
  25226. */
  25227. constructor(name: string, scene: Scene);
  25228. private _hookArray;
  25229. /**
  25230. * Get one of the submaterial by its index in the submaterials array
  25231. * @param index The index to look the sub material at
  25232. * @returns The Material if the index has been defined
  25233. */
  25234. getSubMaterial(index: number): Nullable<Material>;
  25235. /**
  25236. * Get the list of active textures for the whole sub materials list.
  25237. * @returns All the textures that will be used during the rendering
  25238. */
  25239. getActiveTextures(): BaseTexture[];
  25240. /**
  25241. * Gets the current class name of the material e.g. "MultiMaterial"
  25242. * Mainly use in serialization.
  25243. * @returns the class name
  25244. */
  25245. getClassName(): string;
  25246. /**
  25247. * Checks if the material is ready to render the requested sub mesh
  25248. * @param mesh Define the mesh the submesh belongs to
  25249. * @param subMesh Define the sub mesh to look readyness for
  25250. * @param useInstances Define whether or not the material is used with instances
  25251. * @returns true if ready, otherwise false
  25252. */
  25253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25254. /**
  25255. * Clones the current material and its related sub materials
  25256. * @param name Define the name of the newly cloned material
  25257. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25258. * @returns the cloned material
  25259. */
  25260. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25261. /**
  25262. * Serializes the materials into a JSON representation.
  25263. * @returns the JSON representation
  25264. */
  25265. serialize(): any;
  25266. /**
  25267. * Dispose the material and release its associated resources
  25268. * @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)
  25269. * @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)
  25270. * @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)
  25271. */
  25272. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25273. /**
  25274. * Creates a MultiMaterial from parsed MultiMaterial data.
  25275. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25276. * @param scene defines the hosting scene
  25277. * @returns a new MultiMaterial
  25278. */
  25279. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25280. }
  25281. }
  25282. declare module BABYLON {
  25283. /**
  25284. * Defines a subdivision inside a mesh
  25285. */
  25286. export class SubMesh implements ICullable {
  25287. /** the material index to use */
  25288. materialIndex: number;
  25289. /** vertex index start */
  25290. verticesStart: number;
  25291. /** vertices count */
  25292. verticesCount: number;
  25293. /** index start */
  25294. indexStart: number;
  25295. /** indices count */
  25296. indexCount: number;
  25297. /** @hidden */
  25298. _materialDefines: Nullable<MaterialDefines>;
  25299. /** @hidden */
  25300. _materialEffect: Nullable<Effect>;
  25301. /** @hidden */
  25302. _effectOverride: Nullable<Effect>;
  25303. /**
  25304. * Gets material defines used by the effect associated to the sub mesh
  25305. */
  25306. get materialDefines(): Nullable<MaterialDefines>;
  25307. /**
  25308. * Sets material defines used by the effect associated to the sub mesh
  25309. */
  25310. set materialDefines(defines: Nullable<MaterialDefines>);
  25311. /**
  25312. * Gets associated effect
  25313. */
  25314. get effect(): Nullable<Effect>;
  25315. /**
  25316. * Sets associated effect (effect used to render this submesh)
  25317. * @param effect defines the effect to associate with
  25318. * @param defines defines the set of defines used to compile this effect
  25319. */
  25320. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25321. /** @hidden */
  25322. _linesIndexCount: number;
  25323. private _mesh;
  25324. private _renderingMesh;
  25325. private _boundingInfo;
  25326. private _linesIndexBuffer;
  25327. /** @hidden */
  25328. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25329. /** @hidden */
  25330. _trianglePlanes: Plane[];
  25331. /** @hidden */
  25332. _lastColliderTransformMatrix: Nullable<Matrix>;
  25333. /** @hidden */
  25334. _renderId: number;
  25335. /** @hidden */
  25336. _alphaIndex: number;
  25337. /** @hidden */
  25338. _distanceToCamera: number;
  25339. /** @hidden */
  25340. _id: number;
  25341. private _currentMaterial;
  25342. /**
  25343. * Add a new submesh to a mesh
  25344. * @param materialIndex defines the material index to use
  25345. * @param verticesStart defines vertex index start
  25346. * @param verticesCount defines vertices count
  25347. * @param indexStart defines index start
  25348. * @param indexCount defines indices count
  25349. * @param mesh defines the parent mesh
  25350. * @param renderingMesh defines an optional rendering mesh
  25351. * @param createBoundingBox defines if bounding box should be created for this submesh
  25352. * @returns the new submesh
  25353. */
  25354. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25355. /**
  25356. * Creates a new submesh
  25357. * @param materialIndex defines the material index to use
  25358. * @param verticesStart defines vertex index start
  25359. * @param verticesCount defines vertices count
  25360. * @param indexStart defines index start
  25361. * @param indexCount defines indices count
  25362. * @param mesh defines the parent mesh
  25363. * @param renderingMesh defines an optional rendering mesh
  25364. * @param createBoundingBox defines if bounding box should be created for this submesh
  25365. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25366. */
  25367. constructor(
  25368. /** the material index to use */
  25369. materialIndex: number,
  25370. /** vertex index start */
  25371. verticesStart: number,
  25372. /** vertices count */
  25373. verticesCount: number,
  25374. /** index start */
  25375. indexStart: number,
  25376. /** indices count */
  25377. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25378. /**
  25379. * Returns true if this submesh covers the entire parent mesh
  25380. * @ignorenaming
  25381. */
  25382. get IsGlobal(): boolean;
  25383. /**
  25384. * Returns the submesh BoudingInfo object
  25385. * @returns current bounding info (or mesh's one if the submesh is global)
  25386. */
  25387. getBoundingInfo(): BoundingInfo;
  25388. /**
  25389. * Sets the submesh BoundingInfo
  25390. * @param boundingInfo defines the new bounding info to use
  25391. * @returns the SubMesh
  25392. */
  25393. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25394. /**
  25395. * Returns the mesh of the current submesh
  25396. * @return the parent mesh
  25397. */
  25398. getMesh(): AbstractMesh;
  25399. /**
  25400. * Returns the rendering mesh of the submesh
  25401. * @returns the rendering mesh (could be different from parent mesh)
  25402. */
  25403. getRenderingMesh(): Mesh;
  25404. /**
  25405. * Returns the replacement mesh of the submesh
  25406. * @returns the replacement mesh (could be different from parent mesh)
  25407. */
  25408. getReplacementMesh(): Nullable<AbstractMesh>;
  25409. /**
  25410. * Returns the effective mesh of the submesh
  25411. * @returns the effective mesh (could be different from parent mesh)
  25412. */
  25413. getEffectiveMesh(): AbstractMesh;
  25414. /**
  25415. * Returns the submesh material
  25416. * @returns null or the current material
  25417. */
  25418. getMaterial(): Nullable<Material>;
  25419. private _IsMultiMaterial;
  25420. /**
  25421. * Sets a new updated BoundingInfo object to the submesh
  25422. * @param data defines an optional position array to use to determine the bounding info
  25423. * @returns the SubMesh
  25424. */
  25425. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25426. /** @hidden */
  25427. _checkCollision(collider: Collider): boolean;
  25428. /**
  25429. * Updates the submesh BoundingInfo
  25430. * @param world defines the world matrix to use to update the bounding info
  25431. * @returns the submesh
  25432. */
  25433. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25434. /**
  25435. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25436. * @param frustumPlanes defines the frustum planes
  25437. * @returns true if the submesh is intersecting with the frustum
  25438. */
  25439. isInFrustum(frustumPlanes: Plane[]): boolean;
  25440. /**
  25441. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25442. * @param frustumPlanes defines the frustum planes
  25443. * @returns true if the submesh is inside the frustum
  25444. */
  25445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25446. /**
  25447. * Renders the submesh
  25448. * @param enableAlphaMode defines if alpha needs to be used
  25449. * @returns the submesh
  25450. */
  25451. render(enableAlphaMode: boolean): SubMesh;
  25452. /**
  25453. * @hidden
  25454. */
  25455. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25456. /**
  25457. * Checks if the submesh intersects with a ray
  25458. * @param ray defines the ray to test
  25459. * @returns true is the passed ray intersects the submesh bounding box
  25460. */
  25461. canIntersects(ray: Ray): boolean;
  25462. /**
  25463. * Intersects current submesh with a ray
  25464. * @param ray defines the ray to test
  25465. * @param positions defines mesh's positions array
  25466. * @param indices defines mesh's indices array
  25467. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25469. * @returns intersection info or null if no intersection
  25470. */
  25471. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25472. /** @hidden */
  25473. private _intersectLines;
  25474. /** @hidden */
  25475. private _intersectUnIndexedLines;
  25476. /** @hidden */
  25477. private _intersectTriangles;
  25478. /** @hidden */
  25479. private _intersectUnIndexedTriangles;
  25480. /** @hidden */
  25481. _rebuild(): void;
  25482. /**
  25483. * Creates a new submesh from the passed mesh
  25484. * @param newMesh defines the new hosting mesh
  25485. * @param newRenderingMesh defines an optional rendering mesh
  25486. * @returns the new submesh
  25487. */
  25488. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25489. /**
  25490. * Release associated resources
  25491. */
  25492. dispose(): void;
  25493. /**
  25494. * Gets the class name
  25495. * @returns the string "SubMesh".
  25496. */
  25497. getClassName(): string;
  25498. /**
  25499. * Creates a new submesh from indices data
  25500. * @param materialIndex the index of the main mesh material
  25501. * @param startIndex the index where to start the copy in the mesh indices array
  25502. * @param indexCount the number of indices to copy then from the startIndex
  25503. * @param mesh the main mesh to create the submesh from
  25504. * @param renderingMesh the optional rendering mesh
  25505. * @returns a new submesh
  25506. */
  25507. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25508. }
  25509. }
  25510. declare module BABYLON {
  25511. /**
  25512. * Class used to represent data loading progression
  25513. */
  25514. export class SceneLoaderFlags {
  25515. private static _ForceFullSceneLoadingForIncremental;
  25516. private static _ShowLoadingScreen;
  25517. private static _CleanBoneMatrixWeights;
  25518. private static _loggingLevel;
  25519. /**
  25520. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25521. */
  25522. static get ForceFullSceneLoadingForIncremental(): boolean;
  25523. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25524. /**
  25525. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25526. */
  25527. static get ShowLoadingScreen(): boolean;
  25528. static set ShowLoadingScreen(value: boolean);
  25529. /**
  25530. * Defines the current logging level (while loading the scene)
  25531. * @ignorenaming
  25532. */
  25533. static get loggingLevel(): number;
  25534. static set loggingLevel(value: number);
  25535. /**
  25536. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25537. */
  25538. static get CleanBoneMatrixWeights(): boolean;
  25539. static set CleanBoneMatrixWeights(value: boolean);
  25540. }
  25541. }
  25542. declare module BABYLON {
  25543. /**
  25544. * Class used to store geometry data (vertex buffers + index buffer)
  25545. */
  25546. export class Geometry implements IGetSetVerticesData {
  25547. /**
  25548. * Gets or sets the ID of the geometry
  25549. */
  25550. id: string;
  25551. /**
  25552. * Gets or sets the unique ID of the geometry
  25553. */
  25554. uniqueId: number;
  25555. /**
  25556. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25557. */
  25558. delayLoadState: number;
  25559. /**
  25560. * Gets the file containing the data to load when running in delay load state
  25561. */
  25562. delayLoadingFile: Nullable<string>;
  25563. /**
  25564. * Callback called when the geometry is updated
  25565. */
  25566. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25567. private _scene;
  25568. private _engine;
  25569. private _meshes;
  25570. private _totalVertices;
  25571. /** @hidden */
  25572. _indices: IndicesArray;
  25573. /** @hidden */
  25574. _vertexBuffers: {
  25575. [key: string]: VertexBuffer;
  25576. };
  25577. private _isDisposed;
  25578. private _extend;
  25579. private _boundingBias;
  25580. /** @hidden */
  25581. _delayInfo: Array<string>;
  25582. private _indexBuffer;
  25583. private _indexBufferIsUpdatable;
  25584. /** @hidden */
  25585. _boundingInfo: Nullable<BoundingInfo>;
  25586. /** @hidden */
  25587. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25588. /** @hidden */
  25589. _softwareSkinningFrameId: number;
  25590. private _vertexArrayObjects;
  25591. private _updatable;
  25592. /** @hidden */
  25593. _positions: Nullable<Vector3[]>;
  25594. /**
  25595. * 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
  25596. */
  25597. get boundingBias(): Vector2;
  25598. /**
  25599. * 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
  25600. */
  25601. set boundingBias(value: Vector2);
  25602. /**
  25603. * Static function used to attach a new empty geometry to a mesh
  25604. * @param mesh defines the mesh to attach the geometry to
  25605. * @returns the new Geometry
  25606. */
  25607. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25608. /** Get the list of meshes using this geometry */
  25609. get meshes(): Mesh[];
  25610. /**
  25611. * 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
  25612. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25613. */
  25614. useBoundingInfoFromGeometry: boolean;
  25615. /**
  25616. * Creates a new geometry
  25617. * @param id defines the unique ID
  25618. * @param scene defines the hosting scene
  25619. * @param vertexData defines the VertexData used to get geometry data
  25620. * @param updatable defines if geometry must be updatable (false by default)
  25621. * @param mesh defines the mesh that will be associated with the geometry
  25622. */
  25623. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25624. /**
  25625. * Gets the current extend of the geometry
  25626. */
  25627. get extend(): {
  25628. minimum: Vector3;
  25629. maximum: Vector3;
  25630. };
  25631. /**
  25632. * Gets the hosting scene
  25633. * @returns the hosting Scene
  25634. */
  25635. getScene(): Scene;
  25636. /**
  25637. * Gets the hosting engine
  25638. * @returns the hosting Engine
  25639. */
  25640. getEngine(): Engine;
  25641. /**
  25642. * Defines if the geometry is ready to use
  25643. * @returns true if the geometry is ready to be used
  25644. */
  25645. isReady(): boolean;
  25646. /**
  25647. * Gets a value indicating that the geometry should not be serialized
  25648. */
  25649. get doNotSerialize(): boolean;
  25650. /** @hidden */
  25651. _rebuild(): void;
  25652. /**
  25653. * Affects all geometry data in one call
  25654. * @param vertexData defines the geometry data
  25655. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25656. */
  25657. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25658. /**
  25659. * Set specific vertex data
  25660. * @param kind defines the data kind (Position, normal, etc...)
  25661. * @param data defines the vertex data to use
  25662. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25663. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25664. */
  25665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25666. /**
  25667. * Removes a specific vertex data
  25668. * @param kind defines the data kind (Position, normal, etc...)
  25669. */
  25670. removeVerticesData(kind: string): void;
  25671. /**
  25672. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25673. * @param buffer defines the vertex buffer to use
  25674. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25675. */
  25676. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25677. /**
  25678. * Update a specific vertex buffer
  25679. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25680. * It will do nothing if the buffer is not updatable
  25681. * @param kind defines the data kind (Position, normal, etc...)
  25682. * @param data defines the data to use
  25683. * @param offset defines the offset in the target buffer where to store the data
  25684. * @param useBytes set to true if the offset is in bytes
  25685. */
  25686. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25687. /**
  25688. * Update a specific vertex buffer
  25689. * This function will create a new buffer if the current one is not updatable
  25690. * @param kind defines the data kind (Position, normal, etc...)
  25691. * @param data defines the data to use
  25692. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25693. */
  25694. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25695. private _updateBoundingInfo;
  25696. /** @hidden */
  25697. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25698. /**
  25699. * Gets total number of vertices
  25700. * @returns the total number of vertices
  25701. */
  25702. getTotalVertices(): number;
  25703. /**
  25704. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25705. * @param kind defines the data kind (Position, normal, etc...)
  25706. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25707. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25708. * @returns a float array containing vertex data
  25709. */
  25710. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25711. /**
  25712. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25713. * @param kind defines the data kind (Position, normal, etc...)
  25714. * @returns true if the vertex buffer with the specified kind is updatable
  25715. */
  25716. isVertexBufferUpdatable(kind: string): boolean;
  25717. /**
  25718. * Gets a specific vertex buffer
  25719. * @param kind defines the data kind (Position, normal, etc...)
  25720. * @returns a VertexBuffer
  25721. */
  25722. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25723. /**
  25724. * Returns all vertex buffers
  25725. * @return an object holding all vertex buffers indexed by kind
  25726. */
  25727. getVertexBuffers(): Nullable<{
  25728. [key: string]: VertexBuffer;
  25729. }>;
  25730. /**
  25731. * Gets a boolean indicating if specific vertex buffer is present
  25732. * @param kind defines the data kind (Position, normal, etc...)
  25733. * @returns true if data is present
  25734. */
  25735. isVerticesDataPresent(kind: string): boolean;
  25736. /**
  25737. * Gets a list of all attached data kinds (Position, normal, etc...)
  25738. * @returns a list of string containing all kinds
  25739. */
  25740. getVerticesDataKinds(): string[];
  25741. /**
  25742. * Update index buffer
  25743. * @param indices defines the indices to store in the index buffer
  25744. * @param offset defines the offset in the target buffer where to store the data
  25745. * @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)
  25746. */
  25747. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25748. /**
  25749. * Creates a new index buffer
  25750. * @param indices defines the indices to store in the index buffer
  25751. * @param totalVertices defines the total number of vertices (could be null)
  25752. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25753. */
  25754. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25755. /**
  25756. * Return the total number of indices
  25757. * @returns the total number of indices
  25758. */
  25759. getTotalIndices(): number;
  25760. /**
  25761. * Gets the index buffer array
  25762. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25763. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25764. * @returns the index buffer array
  25765. */
  25766. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25767. /**
  25768. * Gets the index buffer
  25769. * @return the index buffer
  25770. */
  25771. getIndexBuffer(): Nullable<DataBuffer>;
  25772. /** @hidden */
  25773. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25774. /**
  25775. * Release the associated resources for a specific mesh
  25776. * @param mesh defines the source mesh
  25777. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25778. */
  25779. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25780. /**
  25781. * Apply current geometry to a given mesh
  25782. * @param mesh defines the mesh to apply geometry to
  25783. */
  25784. applyToMesh(mesh: Mesh): void;
  25785. private _updateExtend;
  25786. private _applyToMesh;
  25787. private notifyUpdate;
  25788. /**
  25789. * Load the geometry if it was flagged as delay loaded
  25790. * @param scene defines the hosting scene
  25791. * @param onLoaded defines a callback called when the geometry is loaded
  25792. */
  25793. load(scene: Scene, onLoaded?: () => void): void;
  25794. private _queueLoad;
  25795. /**
  25796. * Invert the geometry to move from a right handed system to a left handed one.
  25797. */
  25798. toLeftHanded(): void;
  25799. /** @hidden */
  25800. _resetPointsArrayCache(): void;
  25801. /** @hidden */
  25802. _generatePointsArray(): boolean;
  25803. /**
  25804. * Gets a value indicating if the geometry is disposed
  25805. * @returns true if the geometry was disposed
  25806. */
  25807. isDisposed(): boolean;
  25808. private _disposeVertexArrayObjects;
  25809. /**
  25810. * Free all associated resources
  25811. */
  25812. dispose(): void;
  25813. /**
  25814. * Clone the current geometry into a new geometry
  25815. * @param id defines the unique ID of the new geometry
  25816. * @returns a new geometry object
  25817. */
  25818. copy(id: string): Geometry;
  25819. /**
  25820. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25821. * @return a JSON representation of the current geometry data (without the vertices data)
  25822. */
  25823. serialize(): any;
  25824. private toNumberArray;
  25825. /**
  25826. * Serialize all vertices data into a JSON oject
  25827. * @returns a JSON representation of the current geometry data
  25828. */
  25829. serializeVerticeData(): any;
  25830. /**
  25831. * Extracts a clone of a mesh geometry
  25832. * @param mesh defines the source mesh
  25833. * @param id defines the unique ID of the new geometry object
  25834. * @returns the new geometry object
  25835. */
  25836. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25837. /**
  25838. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25839. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25840. * Be aware Math.random() could cause collisions, but:
  25841. * "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"
  25842. * @returns a string containing a new GUID
  25843. */
  25844. static RandomId(): string;
  25845. /** @hidden */
  25846. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25847. private static _CleanMatricesWeights;
  25848. /**
  25849. * Create a new geometry from persisted data (Using .babylon file format)
  25850. * @param parsedVertexData defines the persisted data
  25851. * @param scene defines the hosting scene
  25852. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25853. * @returns the new geometry object
  25854. */
  25855. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25856. }
  25857. }
  25858. declare module BABYLON {
  25859. /**
  25860. * Define an interface for all classes that will get and set the data on vertices
  25861. */
  25862. export interface IGetSetVerticesData {
  25863. /**
  25864. * Gets a boolean indicating if specific vertex data is present
  25865. * @param kind defines the vertex data kind to use
  25866. * @returns true is data kind is present
  25867. */
  25868. isVerticesDataPresent(kind: string): boolean;
  25869. /**
  25870. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25871. * @param kind defines the data kind (Position, normal, etc...)
  25872. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25873. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25874. * @returns a float array containing vertex data
  25875. */
  25876. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25877. /**
  25878. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25879. * @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.
  25880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25881. * @returns the indices array or an empty array if the mesh has no geometry
  25882. */
  25883. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25884. /**
  25885. * Set specific vertex data
  25886. * @param kind defines the data kind (Position, normal, etc...)
  25887. * @param data defines the vertex data to use
  25888. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25889. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25890. */
  25891. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25892. /**
  25893. * Update a specific associated vertex buffer
  25894. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25895. * - VertexBuffer.PositionKind
  25896. * - VertexBuffer.UVKind
  25897. * - VertexBuffer.UV2Kind
  25898. * - VertexBuffer.UV3Kind
  25899. * - VertexBuffer.UV4Kind
  25900. * - VertexBuffer.UV5Kind
  25901. * - VertexBuffer.UV6Kind
  25902. * - VertexBuffer.ColorKind
  25903. * - VertexBuffer.MatricesIndicesKind
  25904. * - VertexBuffer.MatricesIndicesExtraKind
  25905. * - VertexBuffer.MatricesWeightsKind
  25906. * - VertexBuffer.MatricesWeightsExtraKind
  25907. * @param data defines the data source
  25908. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25909. * @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)
  25910. */
  25911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25912. /**
  25913. * Creates a new index buffer
  25914. * @param indices defines the indices to store in the index buffer
  25915. * @param totalVertices defines the total number of vertices (could be null)
  25916. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25917. */
  25918. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25919. }
  25920. /**
  25921. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25922. */
  25923. export class VertexData {
  25924. /**
  25925. * Mesh side orientation : usually the external or front surface
  25926. */
  25927. static readonly FRONTSIDE: number;
  25928. /**
  25929. * Mesh side orientation : usually the internal or back surface
  25930. */
  25931. static readonly BACKSIDE: number;
  25932. /**
  25933. * Mesh side orientation : both internal and external or front and back surfaces
  25934. */
  25935. static readonly DOUBLESIDE: number;
  25936. /**
  25937. * Mesh side orientation : by default, `FRONTSIDE`
  25938. */
  25939. static readonly DEFAULTSIDE: number;
  25940. /**
  25941. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25942. */
  25943. positions: Nullable<FloatArray>;
  25944. /**
  25945. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25946. */
  25947. normals: Nullable<FloatArray>;
  25948. /**
  25949. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25950. */
  25951. tangents: Nullable<FloatArray>;
  25952. /**
  25953. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25954. */
  25955. uvs: Nullable<FloatArray>;
  25956. /**
  25957. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25958. */
  25959. uvs2: Nullable<FloatArray>;
  25960. /**
  25961. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25962. */
  25963. uvs3: Nullable<FloatArray>;
  25964. /**
  25965. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25966. */
  25967. uvs4: Nullable<FloatArray>;
  25968. /**
  25969. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25970. */
  25971. uvs5: Nullable<FloatArray>;
  25972. /**
  25973. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25974. */
  25975. uvs6: Nullable<FloatArray>;
  25976. /**
  25977. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25978. */
  25979. colors: Nullable<FloatArray>;
  25980. /**
  25981. * 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).
  25982. */
  25983. matricesIndices: Nullable<FloatArray>;
  25984. /**
  25985. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25986. */
  25987. matricesWeights: Nullable<FloatArray>;
  25988. /**
  25989. * An array extending the number of possible indices
  25990. */
  25991. matricesIndicesExtra: Nullable<FloatArray>;
  25992. /**
  25993. * An array extending the number of possible weights when the number of indices is extended
  25994. */
  25995. matricesWeightsExtra: Nullable<FloatArray>;
  25996. /**
  25997. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25998. */
  25999. indices: Nullable<IndicesArray>;
  26000. /**
  26001. * Uses the passed data array to set the set the values for the specified kind of data
  26002. * @param data a linear array of floating numbers
  26003. * @param kind the type of data that is being set, eg positions, colors etc
  26004. */
  26005. set(data: FloatArray, kind: string): void;
  26006. /**
  26007. * Associates the vertexData to the passed Mesh.
  26008. * Sets it as updatable or not (default `false`)
  26009. * @param mesh the mesh the vertexData is applied to
  26010. * @param updatable when used and having the value true allows new data to update the vertexData
  26011. * @returns the VertexData
  26012. */
  26013. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26014. /**
  26015. * Associates the vertexData to the passed Geometry.
  26016. * Sets it as updatable or not (default `false`)
  26017. * @param geometry the geometry the vertexData is applied to
  26018. * @param updatable when used and having the value true allows new data to update the vertexData
  26019. * @returns VertexData
  26020. */
  26021. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26022. /**
  26023. * Updates the associated mesh
  26024. * @param mesh the mesh to be updated
  26025. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26026. * @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
  26027. * @returns VertexData
  26028. */
  26029. updateMesh(mesh: Mesh): VertexData;
  26030. /**
  26031. * Updates the associated geometry
  26032. * @param geometry the geometry to be updated
  26033. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26034. * @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
  26035. * @returns VertexData.
  26036. */
  26037. updateGeometry(geometry: Geometry): VertexData;
  26038. private _applyTo;
  26039. private _update;
  26040. /**
  26041. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26042. * @param matrix the transforming matrix
  26043. * @returns the VertexData
  26044. */
  26045. transform(matrix: Matrix): VertexData;
  26046. /**
  26047. * Merges the passed VertexData into the current one
  26048. * @param other the VertexData to be merged into the current one
  26049. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26050. * @returns the modified VertexData
  26051. */
  26052. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26053. private _mergeElement;
  26054. private _validate;
  26055. /**
  26056. * Serializes the VertexData
  26057. * @returns a serialized object
  26058. */
  26059. serialize(): any;
  26060. /**
  26061. * Extracts the vertexData from a mesh
  26062. * @param mesh the mesh from which to extract the VertexData
  26063. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26064. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26065. * @returns the object VertexData associated to the passed mesh
  26066. */
  26067. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26068. /**
  26069. * Extracts the vertexData from the geometry
  26070. * @param geometry the geometry from which to extract the VertexData
  26071. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26072. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26073. * @returns the object VertexData associated to the passed mesh
  26074. */
  26075. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26076. private static _ExtractFrom;
  26077. /**
  26078. * Creates the VertexData for a Ribbon
  26079. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26080. * * pathArray array of paths, each of which an array of successive Vector3
  26081. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26082. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26083. * * 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
  26084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26085. * * 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)
  26086. * * 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)
  26087. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26088. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26089. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26090. * @returns the VertexData of the ribbon
  26091. */
  26092. static CreateRibbon(options: {
  26093. pathArray: Vector3[][];
  26094. closeArray?: boolean;
  26095. closePath?: boolean;
  26096. offset?: number;
  26097. sideOrientation?: number;
  26098. frontUVs?: Vector4;
  26099. backUVs?: Vector4;
  26100. invertUV?: boolean;
  26101. uvs?: Vector2[];
  26102. colors?: Color4[];
  26103. }): VertexData;
  26104. /**
  26105. * Creates the VertexData for a box
  26106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26107. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26108. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26109. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26110. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26111. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26112. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26114. * * 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)
  26115. * * 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)
  26116. * @returns the VertexData of the box
  26117. */
  26118. static CreateBox(options: {
  26119. size?: number;
  26120. width?: number;
  26121. height?: number;
  26122. depth?: number;
  26123. faceUV?: Vector4[];
  26124. faceColors?: Color4[];
  26125. sideOrientation?: number;
  26126. frontUVs?: Vector4;
  26127. backUVs?: Vector4;
  26128. }): VertexData;
  26129. /**
  26130. * Creates the VertexData for a tiled box
  26131. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26132. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26133. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26134. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26136. * @returns the VertexData of the box
  26137. */
  26138. static CreateTiledBox(options: {
  26139. pattern?: number;
  26140. width?: number;
  26141. height?: number;
  26142. depth?: number;
  26143. tileSize?: number;
  26144. tileWidth?: number;
  26145. tileHeight?: number;
  26146. alignHorizontal?: number;
  26147. alignVertical?: number;
  26148. faceUV?: Vector4[];
  26149. faceColors?: Color4[];
  26150. sideOrientation?: number;
  26151. }): VertexData;
  26152. /**
  26153. * Creates the VertexData for a tiled plane
  26154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26155. * * pattern a limited pattern arrangement depending on the number
  26156. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26157. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26158. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26160. * * 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)
  26161. * * 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)
  26162. * @returns the VertexData of the tiled plane
  26163. */
  26164. static CreateTiledPlane(options: {
  26165. pattern?: number;
  26166. tileSize?: number;
  26167. tileWidth?: number;
  26168. tileHeight?: number;
  26169. size?: number;
  26170. width?: number;
  26171. height?: number;
  26172. alignHorizontal?: number;
  26173. alignVertical?: number;
  26174. sideOrientation?: number;
  26175. frontUVs?: Vector4;
  26176. backUVs?: Vector4;
  26177. }): VertexData;
  26178. /**
  26179. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26181. * * segments sets the number of horizontal strips optional, default 32
  26182. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26183. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26184. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26185. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26186. * * 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
  26187. * * 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
  26188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26189. * * 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)
  26190. * * 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)
  26191. * @returns the VertexData of the ellipsoid
  26192. */
  26193. static CreateSphere(options: {
  26194. segments?: number;
  26195. diameter?: number;
  26196. diameterX?: number;
  26197. diameterY?: number;
  26198. diameterZ?: number;
  26199. arc?: number;
  26200. slice?: number;
  26201. sideOrientation?: number;
  26202. frontUVs?: Vector4;
  26203. backUVs?: Vector4;
  26204. }): VertexData;
  26205. /**
  26206. * Creates the VertexData for a cylinder, cone or prism
  26207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26208. * * height sets the height (y direction) of the cylinder, optional, default 2
  26209. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26210. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26211. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26212. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26213. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26214. * * 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
  26215. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26216. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26217. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26218. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26220. * * 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)
  26221. * * 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)
  26222. * @returns the VertexData of the cylinder, cone or prism
  26223. */
  26224. static CreateCylinder(options: {
  26225. height?: number;
  26226. diameterTop?: number;
  26227. diameterBottom?: number;
  26228. diameter?: number;
  26229. tessellation?: number;
  26230. subdivisions?: number;
  26231. arc?: number;
  26232. faceColors?: Color4[];
  26233. faceUV?: Vector4[];
  26234. hasRings?: boolean;
  26235. enclose?: boolean;
  26236. sideOrientation?: number;
  26237. frontUVs?: Vector4;
  26238. backUVs?: Vector4;
  26239. }): VertexData;
  26240. /**
  26241. * Creates the VertexData for a torus
  26242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26243. * * diameter the diameter of the torus, optional default 1
  26244. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26245. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26247. * * 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)
  26248. * * 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)
  26249. * @returns the VertexData of the torus
  26250. */
  26251. static CreateTorus(options: {
  26252. diameter?: number;
  26253. thickness?: number;
  26254. tessellation?: number;
  26255. sideOrientation?: number;
  26256. frontUVs?: Vector4;
  26257. backUVs?: Vector4;
  26258. }): VertexData;
  26259. /**
  26260. * Creates the VertexData of the LineSystem
  26261. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26262. * - lines an array of lines, each line being an array of successive Vector3
  26263. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26264. * @returns the VertexData of the LineSystem
  26265. */
  26266. static CreateLineSystem(options: {
  26267. lines: Vector3[][];
  26268. colors?: Nullable<Color4[][]>;
  26269. }): VertexData;
  26270. /**
  26271. * Create the VertexData for a DashedLines
  26272. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26273. * - points an array successive Vector3
  26274. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26275. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26276. * - dashNb the intended total number of dashes, optional, default 200
  26277. * @returns the VertexData for the DashedLines
  26278. */
  26279. static CreateDashedLines(options: {
  26280. points: Vector3[];
  26281. dashSize?: number;
  26282. gapSize?: number;
  26283. dashNb?: number;
  26284. }): VertexData;
  26285. /**
  26286. * Creates the VertexData for a Ground
  26287. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26288. * - width the width (x direction) of the ground, optional, default 1
  26289. * - height the height (z direction) of the ground, optional, default 1
  26290. * - subdivisions the number of subdivisions per side, optional, default 1
  26291. * @returns the VertexData of the Ground
  26292. */
  26293. static CreateGround(options: {
  26294. width?: number;
  26295. height?: number;
  26296. subdivisions?: number;
  26297. subdivisionsX?: number;
  26298. subdivisionsY?: number;
  26299. }): VertexData;
  26300. /**
  26301. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26302. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26303. * * xmin the ground minimum X coordinate, optional, default -1
  26304. * * zmin the ground minimum Z coordinate, optional, default -1
  26305. * * xmax the ground maximum X coordinate, optional, default 1
  26306. * * zmax the ground maximum Z coordinate, optional, default 1
  26307. * * 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}
  26308. * * 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}
  26309. * @returns the VertexData of the TiledGround
  26310. */
  26311. static CreateTiledGround(options: {
  26312. xmin: number;
  26313. zmin: number;
  26314. xmax: number;
  26315. zmax: number;
  26316. subdivisions?: {
  26317. w: number;
  26318. h: number;
  26319. };
  26320. precision?: {
  26321. w: number;
  26322. h: number;
  26323. };
  26324. }): VertexData;
  26325. /**
  26326. * Creates the VertexData of the Ground designed from a heightmap
  26327. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26328. * * width the width (x direction) of the ground
  26329. * * height the height (z direction) of the ground
  26330. * * subdivisions the number of subdivisions per side
  26331. * * minHeight the minimum altitude on the ground, optional, default 0
  26332. * * maxHeight the maximum altitude on the ground, optional default 1
  26333. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26334. * * buffer the array holding the image color data
  26335. * * bufferWidth the width of image
  26336. * * bufferHeight the height of image
  26337. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26338. * @returns the VertexData of the Ground designed from a heightmap
  26339. */
  26340. static CreateGroundFromHeightMap(options: {
  26341. width: number;
  26342. height: number;
  26343. subdivisions: number;
  26344. minHeight: number;
  26345. maxHeight: number;
  26346. colorFilter: Color3;
  26347. buffer: Uint8Array;
  26348. bufferWidth: number;
  26349. bufferHeight: number;
  26350. alphaFilter: number;
  26351. }): VertexData;
  26352. /**
  26353. * Creates the VertexData for a Plane
  26354. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26355. * * size sets the width and height of the plane to the value of size, optional default 1
  26356. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26357. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26359. * * 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)
  26360. * * 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)
  26361. * @returns the VertexData of the box
  26362. */
  26363. static CreatePlane(options: {
  26364. size?: number;
  26365. width?: number;
  26366. height?: number;
  26367. sideOrientation?: number;
  26368. frontUVs?: Vector4;
  26369. backUVs?: Vector4;
  26370. }): VertexData;
  26371. /**
  26372. * Creates the VertexData of the Disc or regular Polygon
  26373. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26374. * * radius the radius of the disc, optional default 0.5
  26375. * * tessellation the number of polygon sides, optional, default 64
  26376. * * 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
  26377. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26378. * * 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)
  26379. * * 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)
  26380. * @returns the VertexData of the box
  26381. */
  26382. static CreateDisc(options: {
  26383. radius?: number;
  26384. tessellation?: number;
  26385. arc?: number;
  26386. sideOrientation?: number;
  26387. frontUVs?: Vector4;
  26388. backUVs?: Vector4;
  26389. }): VertexData;
  26390. /**
  26391. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26392. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26393. * @param polygon a mesh built from polygonTriangulation.build()
  26394. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26395. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26396. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26397. * @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)
  26398. * @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)
  26399. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26400. * @returns the VertexData of the Polygon
  26401. */
  26402. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26403. /**
  26404. * Creates the VertexData of the IcoSphere
  26405. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26406. * * radius the radius of the IcoSphere, optional default 1
  26407. * * radiusX allows stretching in the x direction, optional, default radius
  26408. * * radiusY allows stretching in the y direction, optional, default radius
  26409. * * radiusZ allows stretching in the z direction, optional, default radius
  26410. * * flat when true creates a flat shaded mesh, optional, default true
  26411. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26413. * * 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)
  26414. * * 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)
  26415. * @returns the VertexData of the IcoSphere
  26416. */
  26417. static CreateIcoSphere(options: {
  26418. radius?: number;
  26419. radiusX?: number;
  26420. radiusY?: number;
  26421. radiusZ?: number;
  26422. flat?: boolean;
  26423. subdivisions?: number;
  26424. sideOrientation?: number;
  26425. frontUVs?: Vector4;
  26426. backUVs?: Vector4;
  26427. }): VertexData;
  26428. /**
  26429. * Creates the VertexData for a Polyhedron
  26430. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26431. * * type provided types are:
  26432. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26433. * * 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)
  26434. * * size the size of the IcoSphere, optional default 1
  26435. * * sizeX allows stretching in the x direction, optional, default size
  26436. * * sizeY allows stretching in the y direction, optional, default size
  26437. * * sizeZ allows stretching in the z direction, optional, default size
  26438. * * 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
  26439. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26440. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26441. * * flat when true creates a flat shaded mesh, optional, default true
  26442. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26444. * * 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)
  26445. * * 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)
  26446. * @returns the VertexData of the Polyhedron
  26447. */
  26448. static CreatePolyhedron(options: {
  26449. type?: number;
  26450. size?: number;
  26451. sizeX?: number;
  26452. sizeY?: number;
  26453. sizeZ?: number;
  26454. custom?: any;
  26455. faceUV?: Vector4[];
  26456. faceColors?: Color4[];
  26457. flat?: boolean;
  26458. sideOrientation?: number;
  26459. frontUVs?: Vector4;
  26460. backUVs?: Vector4;
  26461. }): VertexData;
  26462. /**
  26463. * Creates the VertexData for a TorusKnot
  26464. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26465. * * radius the radius of the torus knot, optional, default 2
  26466. * * tube the thickness of the tube, optional, default 0.5
  26467. * * radialSegments the number of sides on each tube segments, optional, default 32
  26468. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26469. * * p the number of windings around the z axis, optional, default 2
  26470. * * q the number of windings around the x axis, optional, default 3
  26471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26472. * * 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)
  26473. * * 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)
  26474. * @returns the VertexData of the Torus Knot
  26475. */
  26476. static CreateTorusKnot(options: {
  26477. radius?: number;
  26478. tube?: number;
  26479. radialSegments?: number;
  26480. tubularSegments?: number;
  26481. p?: number;
  26482. q?: number;
  26483. sideOrientation?: number;
  26484. frontUVs?: Vector4;
  26485. backUVs?: Vector4;
  26486. }): VertexData;
  26487. /**
  26488. * Compute normals for given positions and indices
  26489. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26490. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26491. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26492. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26493. * * facetNormals : optional array of facet normals (vector3)
  26494. * * facetPositions : optional array of facet positions (vector3)
  26495. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26496. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26497. * * bInfo : optional bounding info, required for facetPartitioning computation
  26498. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26499. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26500. * * useRightHandedSystem: optional boolean to for right handed system computation
  26501. * * depthSort : optional boolean to enable the facet depth sort computation
  26502. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26503. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26504. */
  26505. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26506. facetNormals?: any;
  26507. facetPositions?: any;
  26508. facetPartitioning?: any;
  26509. ratio?: number;
  26510. bInfo?: any;
  26511. bbSize?: Vector3;
  26512. subDiv?: any;
  26513. useRightHandedSystem?: boolean;
  26514. depthSort?: boolean;
  26515. distanceTo?: Vector3;
  26516. depthSortedFacets?: any;
  26517. }): void;
  26518. /** @hidden */
  26519. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26520. /**
  26521. * Applies VertexData created from the imported parameters to the geometry
  26522. * @param parsedVertexData the parsed data from an imported file
  26523. * @param geometry the geometry to apply the VertexData to
  26524. */
  26525. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26526. }
  26527. }
  26528. declare module BABYLON {
  26529. /**
  26530. * Defines a target to use with MorphTargetManager
  26531. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26532. */
  26533. export class MorphTarget implements IAnimatable {
  26534. /** defines the name of the target */
  26535. name: string;
  26536. /**
  26537. * Gets or sets the list of animations
  26538. */
  26539. animations: Animation[];
  26540. private _scene;
  26541. private _positions;
  26542. private _normals;
  26543. private _tangents;
  26544. private _uvs;
  26545. private _influence;
  26546. private _uniqueId;
  26547. /**
  26548. * Observable raised when the influence changes
  26549. */
  26550. onInfluenceChanged: Observable<boolean>;
  26551. /** @hidden */
  26552. _onDataLayoutChanged: Observable<void>;
  26553. /**
  26554. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26555. */
  26556. get influence(): number;
  26557. set influence(influence: number);
  26558. /**
  26559. * Gets or sets the id of the morph Target
  26560. */
  26561. id: string;
  26562. private _animationPropertiesOverride;
  26563. /**
  26564. * Gets or sets the animation properties override
  26565. */
  26566. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26567. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26568. /**
  26569. * Creates a new MorphTarget
  26570. * @param name defines the name of the target
  26571. * @param influence defines the influence to use
  26572. * @param scene defines the scene the morphtarget belongs to
  26573. */
  26574. constructor(
  26575. /** defines the name of the target */
  26576. name: string, influence?: number, scene?: Nullable<Scene>);
  26577. /**
  26578. * Gets the unique ID of this manager
  26579. */
  26580. get uniqueId(): number;
  26581. /**
  26582. * Gets a boolean defining if the target contains position data
  26583. */
  26584. get hasPositions(): boolean;
  26585. /**
  26586. * Gets a boolean defining if the target contains normal data
  26587. */
  26588. get hasNormals(): boolean;
  26589. /**
  26590. * Gets a boolean defining if the target contains tangent data
  26591. */
  26592. get hasTangents(): boolean;
  26593. /**
  26594. * Gets a boolean defining if the target contains texture coordinates data
  26595. */
  26596. get hasUVs(): boolean;
  26597. /**
  26598. * Affects position data to this target
  26599. * @param data defines the position data to use
  26600. */
  26601. setPositions(data: Nullable<FloatArray>): void;
  26602. /**
  26603. * Gets the position data stored in this target
  26604. * @returns a FloatArray containing the position data (or null if not present)
  26605. */
  26606. getPositions(): Nullable<FloatArray>;
  26607. /**
  26608. * Affects normal data to this target
  26609. * @param data defines the normal data to use
  26610. */
  26611. setNormals(data: Nullable<FloatArray>): void;
  26612. /**
  26613. * Gets the normal data stored in this target
  26614. * @returns a FloatArray containing the normal data (or null if not present)
  26615. */
  26616. getNormals(): Nullable<FloatArray>;
  26617. /**
  26618. * Affects tangent data to this target
  26619. * @param data defines the tangent data to use
  26620. */
  26621. setTangents(data: Nullable<FloatArray>): void;
  26622. /**
  26623. * Gets the tangent data stored in this target
  26624. * @returns a FloatArray containing the tangent data (or null if not present)
  26625. */
  26626. getTangents(): Nullable<FloatArray>;
  26627. /**
  26628. * Affects texture coordinates data to this target
  26629. * @param data defines the texture coordinates data to use
  26630. */
  26631. setUVs(data: Nullable<FloatArray>): void;
  26632. /**
  26633. * Gets the texture coordinates data stored in this target
  26634. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26635. */
  26636. getUVs(): Nullable<FloatArray>;
  26637. /**
  26638. * Clone the current target
  26639. * @returns a new MorphTarget
  26640. */
  26641. clone(): MorphTarget;
  26642. /**
  26643. * Serializes the current target into a Serialization object
  26644. * @returns the serialized object
  26645. */
  26646. serialize(): any;
  26647. /**
  26648. * Returns the string "MorphTarget"
  26649. * @returns "MorphTarget"
  26650. */
  26651. getClassName(): string;
  26652. /**
  26653. * Creates a new target from serialized data
  26654. * @param serializationObject defines the serialized data to use
  26655. * @returns a new MorphTarget
  26656. */
  26657. static Parse(serializationObject: any): MorphTarget;
  26658. /**
  26659. * Creates a MorphTarget from mesh data
  26660. * @param mesh defines the source mesh
  26661. * @param name defines the name to use for the new target
  26662. * @param influence defines the influence to attach to the target
  26663. * @returns a new MorphTarget
  26664. */
  26665. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26666. }
  26667. }
  26668. declare module BABYLON {
  26669. /**
  26670. * This class is used to deform meshes using morphing between different targets
  26671. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26672. */
  26673. export class MorphTargetManager {
  26674. private _targets;
  26675. private _targetInfluenceChangedObservers;
  26676. private _targetDataLayoutChangedObservers;
  26677. private _activeTargets;
  26678. private _scene;
  26679. private _influences;
  26680. private _supportsNormals;
  26681. private _supportsTangents;
  26682. private _supportsUVs;
  26683. private _vertexCount;
  26684. private _uniqueId;
  26685. private _tempInfluences;
  26686. /**
  26687. * Gets or sets a boolean indicating if normals must be morphed
  26688. */
  26689. enableNormalMorphing: boolean;
  26690. /**
  26691. * Gets or sets a boolean indicating if tangents must be morphed
  26692. */
  26693. enableTangentMorphing: boolean;
  26694. /**
  26695. * Gets or sets a boolean indicating if UV must be morphed
  26696. */
  26697. enableUVMorphing: boolean;
  26698. /**
  26699. * Creates a new MorphTargetManager
  26700. * @param scene defines the current scene
  26701. */
  26702. constructor(scene?: Nullable<Scene>);
  26703. /**
  26704. * Gets the unique ID of this manager
  26705. */
  26706. get uniqueId(): number;
  26707. /**
  26708. * Gets the number of vertices handled by this manager
  26709. */
  26710. get vertexCount(): number;
  26711. /**
  26712. * Gets a boolean indicating if this manager supports morphing of normals
  26713. */
  26714. get supportsNormals(): boolean;
  26715. /**
  26716. * Gets a boolean indicating if this manager supports morphing of tangents
  26717. */
  26718. get supportsTangents(): boolean;
  26719. /**
  26720. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26721. */
  26722. get supportsUVs(): boolean;
  26723. /**
  26724. * Gets the number of targets stored in this manager
  26725. */
  26726. get numTargets(): number;
  26727. /**
  26728. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26729. */
  26730. get numInfluencers(): number;
  26731. /**
  26732. * Gets the list of influences (one per target)
  26733. */
  26734. get influences(): Float32Array;
  26735. /**
  26736. * Gets the active target at specified index. An active target is a target with an influence > 0
  26737. * @param index defines the index to check
  26738. * @returns the requested target
  26739. */
  26740. getActiveTarget(index: number): MorphTarget;
  26741. /**
  26742. * Gets the target at specified index
  26743. * @param index defines the index to check
  26744. * @returns the requested target
  26745. */
  26746. getTarget(index: number): MorphTarget;
  26747. /**
  26748. * Add a new target to this manager
  26749. * @param target defines the target to add
  26750. */
  26751. addTarget(target: MorphTarget): void;
  26752. /**
  26753. * Removes a target from the manager
  26754. * @param target defines the target to remove
  26755. */
  26756. removeTarget(target: MorphTarget): void;
  26757. /**
  26758. * Clone the current manager
  26759. * @returns a new MorphTargetManager
  26760. */
  26761. clone(): MorphTargetManager;
  26762. /**
  26763. * Serializes the current manager into a Serialization object
  26764. * @returns the serialized object
  26765. */
  26766. serialize(): any;
  26767. private _syncActiveTargets;
  26768. /**
  26769. * Syncrhonize the targets with all the meshes using this morph target manager
  26770. */
  26771. synchronize(): void;
  26772. /**
  26773. * Creates a new MorphTargetManager from serialized data
  26774. * @param serializationObject defines the serialized data
  26775. * @param scene defines the hosting scene
  26776. * @returns the new MorphTargetManager
  26777. */
  26778. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26779. }
  26780. }
  26781. declare module BABYLON {
  26782. /**
  26783. * Class used to represent a specific level of detail of a mesh
  26784. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26785. */
  26786. export class MeshLODLevel {
  26787. /** Defines the distance where this level should start being displayed */
  26788. distance: number;
  26789. /** Defines the mesh to use to render this level */
  26790. mesh: Nullable<Mesh>;
  26791. /**
  26792. * Creates a new LOD level
  26793. * @param distance defines the distance where this level should star being displayed
  26794. * @param mesh defines the mesh to use to render this level
  26795. */
  26796. constructor(
  26797. /** Defines the distance where this level should start being displayed */
  26798. distance: number,
  26799. /** Defines the mesh to use to render this level */
  26800. mesh: Nullable<Mesh>);
  26801. }
  26802. }
  26803. declare module BABYLON {
  26804. /**
  26805. * Helper class used to generate a canvas to manipulate images
  26806. */
  26807. export class CanvasGenerator {
  26808. /**
  26809. * Create a new canvas (or offscreen canvas depending on the context)
  26810. * @param width defines the expected width
  26811. * @param height defines the expected height
  26812. * @return a new canvas or offscreen canvas
  26813. */
  26814. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26815. }
  26816. }
  26817. declare module BABYLON {
  26818. /**
  26819. * Mesh representing the gorund
  26820. */
  26821. export class GroundMesh extends Mesh {
  26822. /** If octree should be generated */
  26823. generateOctree: boolean;
  26824. private _heightQuads;
  26825. /** @hidden */
  26826. _subdivisionsX: number;
  26827. /** @hidden */
  26828. _subdivisionsY: number;
  26829. /** @hidden */
  26830. _width: number;
  26831. /** @hidden */
  26832. _height: number;
  26833. /** @hidden */
  26834. _minX: number;
  26835. /** @hidden */
  26836. _maxX: number;
  26837. /** @hidden */
  26838. _minZ: number;
  26839. /** @hidden */
  26840. _maxZ: number;
  26841. constructor(name: string, scene: Scene);
  26842. /**
  26843. * "GroundMesh"
  26844. * @returns "GroundMesh"
  26845. */
  26846. getClassName(): string;
  26847. /**
  26848. * The minimum of x and y subdivisions
  26849. */
  26850. get subdivisions(): number;
  26851. /**
  26852. * X subdivisions
  26853. */
  26854. get subdivisionsX(): number;
  26855. /**
  26856. * Y subdivisions
  26857. */
  26858. get subdivisionsY(): number;
  26859. /**
  26860. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26861. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26862. * @param chunksCount the number of subdivisions for x and y
  26863. * @param octreeBlocksSize (Default: 32)
  26864. */
  26865. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26866. /**
  26867. * Returns a height (y) value in the Worl system :
  26868. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26869. * @param x x coordinate
  26870. * @param z z coordinate
  26871. * @returns the ground y position if (x, z) are outside the ground surface.
  26872. */
  26873. getHeightAtCoordinates(x: number, z: number): number;
  26874. /**
  26875. * Returns a normalized vector (Vector3) orthogonal to the ground
  26876. * at the ground coordinates (x, z) expressed in the World system.
  26877. * @param x x coordinate
  26878. * @param z z coordinate
  26879. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26880. */
  26881. getNormalAtCoordinates(x: number, z: number): Vector3;
  26882. /**
  26883. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26884. * at the ground coordinates (x, z) expressed in the World system.
  26885. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26886. * @param x x coordinate
  26887. * @param z z coordinate
  26888. * @param ref vector to store the result
  26889. * @returns the GroundMesh.
  26890. */
  26891. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26892. /**
  26893. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26894. * if the ground has been updated.
  26895. * This can be used in the render loop.
  26896. * @returns the GroundMesh.
  26897. */
  26898. updateCoordinateHeights(): GroundMesh;
  26899. private _getFacetAt;
  26900. private _initHeightQuads;
  26901. private _computeHeightQuads;
  26902. /**
  26903. * Serializes this ground mesh
  26904. * @param serializationObject object to write serialization to
  26905. */
  26906. serialize(serializationObject: any): void;
  26907. /**
  26908. * Parses a serialized ground mesh
  26909. * @param parsedMesh the serialized mesh
  26910. * @param scene the scene to create the ground mesh in
  26911. * @returns the created ground mesh
  26912. */
  26913. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26914. }
  26915. }
  26916. declare module BABYLON {
  26917. /**
  26918. * Interface for Physics-Joint data
  26919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26920. */
  26921. export interface PhysicsJointData {
  26922. /**
  26923. * The main pivot of the joint
  26924. */
  26925. mainPivot?: Vector3;
  26926. /**
  26927. * The connected pivot of the joint
  26928. */
  26929. connectedPivot?: Vector3;
  26930. /**
  26931. * The main axis of the joint
  26932. */
  26933. mainAxis?: Vector3;
  26934. /**
  26935. * The connected axis of the joint
  26936. */
  26937. connectedAxis?: Vector3;
  26938. /**
  26939. * The collision of the joint
  26940. */
  26941. collision?: boolean;
  26942. /**
  26943. * Native Oimo/Cannon/Energy data
  26944. */
  26945. nativeParams?: any;
  26946. }
  26947. /**
  26948. * This is a holder class for the physics joint created by the physics plugin
  26949. * It holds a set of functions to control the underlying joint
  26950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26951. */
  26952. export class PhysicsJoint {
  26953. /**
  26954. * The type of the physics joint
  26955. */
  26956. type: number;
  26957. /**
  26958. * The data for the physics joint
  26959. */
  26960. jointData: PhysicsJointData;
  26961. private _physicsJoint;
  26962. protected _physicsPlugin: IPhysicsEnginePlugin;
  26963. /**
  26964. * Initializes the physics joint
  26965. * @param type The type of the physics joint
  26966. * @param jointData The data for the physics joint
  26967. */
  26968. constructor(
  26969. /**
  26970. * The type of the physics joint
  26971. */
  26972. type: number,
  26973. /**
  26974. * The data for the physics joint
  26975. */
  26976. jointData: PhysicsJointData);
  26977. /**
  26978. * Gets the physics joint
  26979. */
  26980. get physicsJoint(): any;
  26981. /**
  26982. * Sets the physics joint
  26983. */
  26984. set physicsJoint(newJoint: any);
  26985. /**
  26986. * Sets the physics plugin
  26987. */
  26988. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26989. /**
  26990. * Execute a function that is physics-plugin specific.
  26991. * @param {Function} func the function that will be executed.
  26992. * It accepts two parameters: the physics world and the physics joint
  26993. */
  26994. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26995. /**
  26996. * Distance-Joint type
  26997. */
  26998. static DistanceJoint: number;
  26999. /**
  27000. * Hinge-Joint type
  27001. */
  27002. static HingeJoint: number;
  27003. /**
  27004. * Ball-and-Socket joint type
  27005. */
  27006. static BallAndSocketJoint: number;
  27007. /**
  27008. * Wheel-Joint type
  27009. */
  27010. static WheelJoint: number;
  27011. /**
  27012. * Slider-Joint type
  27013. */
  27014. static SliderJoint: number;
  27015. /**
  27016. * Prismatic-Joint type
  27017. */
  27018. static PrismaticJoint: number;
  27019. /**
  27020. * Universal-Joint type
  27021. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27022. */
  27023. static UniversalJoint: number;
  27024. /**
  27025. * Hinge-Joint 2 type
  27026. */
  27027. static Hinge2Joint: number;
  27028. /**
  27029. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27030. */
  27031. static PointToPointJoint: number;
  27032. /**
  27033. * Spring-Joint type
  27034. */
  27035. static SpringJoint: number;
  27036. /**
  27037. * Lock-Joint type
  27038. */
  27039. static LockJoint: number;
  27040. }
  27041. /**
  27042. * A class representing a physics distance joint
  27043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27044. */
  27045. export class DistanceJoint extends PhysicsJoint {
  27046. /**
  27047. *
  27048. * @param jointData The data for the Distance-Joint
  27049. */
  27050. constructor(jointData: DistanceJointData);
  27051. /**
  27052. * Update the predefined distance.
  27053. * @param maxDistance The maximum preferred distance
  27054. * @param minDistance The minimum preferred distance
  27055. */
  27056. updateDistance(maxDistance: number, minDistance?: number): void;
  27057. }
  27058. /**
  27059. * Represents a Motor-Enabled Joint
  27060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27061. */
  27062. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27063. /**
  27064. * Initializes the Motor-Enabled Joint
  27065. * @param type The type of the joint
  27066. * @param jointData The physica joint data for the joint
  27067. */
  27068. constructor(type: number, jointData: PhysicsJointData);
  27069. /**
  27070. * Set the motor values.
  27071. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27072. * @param force the force to apply
  27073. * @param maxForce max force for this motor.
  27074. */
  27075. setMotor(force?: number, maxForce?: number): void;
  27076. /**
  27077. * Set the motor's limits.
  27078. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27079. * @param upperLimit The upper limit of the motor
  27080. * @param lowerLimit The lower limit of the motor
  27081. */
  27082. setLimit(upperLimit: number, lowerLimit?: number): void;
  27083. }
  27084. /**
  27085. * This class represents a single physics Hinge-Joint
  27086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27087. */
  27088. export class HingeJoint extends MotorEnabledJoint {
  27089. /**
  27090. * Initializes the Hinge-Joint
  27091. * @param jointData The joint data for the Hinge-Joint
  27092. */
  27093. constructor(jointData: PhysicsJointData);
  27094. /**
  27095. * Set the motor values.
  27096. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27097. * @param {number} force the force to apply
  27098. * @param {number} maxForce max force for this motor.
  27099. */
  27100. setMotor(force?: number, maxForce?: number): void;
  27101. /**
  27102. * Set the motor's limits.
  27103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27104. * @param upperLimit The upper limit of the motor
  27105. * @param lowerLimit The lower limit of the motor
  27106. */
  27107. setLimit(upperLimit: number, lowerLimit?: number): void;
  27108. }
  27109. /**
  27110. * This class represents a dual hinge physics joint (same as wheel joint)
  27111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27112. */
  27113. export class Hinge2Joint extends MotorEnabledJoint {
  27114. /**
  27115. * Initializes the Hinge2-Joint
  27116. * @param jointData The joint data for the Hinge2-Joint
  27117. */
  27118. constructor(jointData: PhysicsJointData);
  27119. /**
  27120. * Set the motor values.
  27121. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27122. * @param {number} targetSpeed the speed the motor is to reach
  27123. * @param {number} maxForce max force for this motor.
  27124. * @param {motorIndex} the motor's index, 0 or 1.
  27125. */
  27126. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27127. /**
  27128. * Set the motor limits.
  27129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27130. * @param {number} upperLimit the upper limit
  27131. * @param {number} lowerLimit lower limit
  27132. * @param {motorIndex} the motor's index, 0 or 1.
  27133. */
  27134. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27135. }
  27136. /**
  27137. * Interface for a motor enabled joint
  27138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27139. */
  27140. export interface IMotorEnabledJoint {
  27141. /**
  27142. * Physics joint
  27143. */
  27144. physicsJoint: any;
  27145. /**
  27146. * Sets the motor of the motor-enabled joint
  27147. * @param force The force of the motor
  27148. * @param maxForce The maximum force of the motor
  27149. * @param motorIndex The index of the motor
  27150. */
  27151. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27152. /**
  27153. * Sets the limit of the motor
  27154. * @param upperLimit The upper limit of the motor
  27155. * @param lowerLimit The lower limit of the motor
  27156. * @param motorIndex The index of the motor
  27157. */
  27158. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27159. }
  27160. /**
  27161. * Joint data for a Distance-Joint
  27162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27163. */
  27164. export interface DistanceJointData extends PhysicsJointData {
  27165. /**
  27166. * Max distance the 2 joint objects can be apart
  27167. */
  27168. maxDistance: number;
  27169. }
  27170. /**
  27171. * Joint data from a spring joint
  27172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27173. */
  27174. export interface SpringJointData extends PhysicsJointData {
  27175. /**
  27176. * Length of the spring
  27177. */
  27178. length: number;
  27179. /**
  27180. * Stiffness of the spring
  27181. */
  27182. stiffness: number;
  27183. /**
  27184. * Damping of the spring
  27185. */
  27186. damping: number;
  27187. /** this callback will be called when applying the force to the impostors. */
  27188. forceApplicationCallback: () => void;
  27189. }
  27190. }
  27191. declare module BABYLON {
  27192. /**
  27193. * Holds the data for the raycast result
  27194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27195. */
  27196. export class PhysicsRaycastResult {
  27197. private _hasHit;
  27198. private _hitDistance;
  27199. private _hitNormalWorld;
  27200. private _hitPointWorld;
  27201. private _rayFromWorld;
  27202. private _rayToWorld;
  27203. /**
  27204. * Gets if there was a hit
  27205. */
  27206. get hasHit(): boolean;
  27207. /**
  27208. * Gets the distance from the hit
  27209. */
  27210. get hitDistance(): number;
  27211. /**
  27212. * Gets the hit normal/direction in the world
  27213. */
  27214. get hitNormalWorld(): Vector3;
  27215. /**
  27216. * Gets the hit point in the world
  27217. */
  27218. get hitPointWorld(): Vector3;
  27219. /**
  27220. * Gets the ray "start point" of the ray in the world
  27221. */
  27222. get rayFromWorld(): Vector3;
  27223. /**
  27224. * Gets the ray "end point" of the ray in the world
  27225. */
  27226. get rayToWorld(): Vector3;
  27227. /**
  27228. * Sets the hit data (normal & point in world space)
  27229. * @param hitNormalWorld defines the normal in world space
  27230. * @param hitPointWorld defines the point in world space
  27231. */
  27232. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27233. /**
  27234. * Sets the distance from the start point to the hit point
  27235. * @param distance
  27236. */
  27237. setHitDistance(distance: number): void;
  27238. /**
  27239. * Calculates the distance manually
  27240. */
  27241. calculateHitDistance(): void;
  27242. /**
  27243. * Resets all the values to default
  27244. * @param from The from point on world space
  27245. * @param to The to point on world space
  27246. */
  27247. reset(from?: Vector3, to?: Vector3): void;
  27248. }
  27249. /**
  27250. * Interface for the size containing width and height
  27251. */
  27252. interface IXYZ {
  27253. /**
  27254. * X
  27255. */
  27256. x: number;
  27257. /**
  27258. * Y
  27259. */
  27260. y: number;
  27261. /**
  27262. * Z
  27263. */
  27264. z: number;
  27265. }
  27266. }
  27267. declare module BABYLON {
  27268. /**
  27269. * Interface used to describe a physics joint
  27270. */
  27271. export interface PhysicsImpostorJoint {
  27272. /** Defines the main impostor to which the joint is linked */
  27273. mainImpostor: PhysicsImpostor;
  27274. /** Defines the impostor that is connected to the main impostor using this joint */
  27275. connectedImpostor: PhysicsImpostor;
  27276. /** Defines the joint itself */
  27277. joint: PhysicsJoint;
  27278. }
  27279. /** @hidden */
  27280. export interface IPhysicsEnginePlugin {
  27281. world: any;
  27282. name: string;
  27283. setGravity(gravity: Vector3): void;
  27284. setTimeStep(timeStep: number): void;
  27285. getTimeStep(): number;
  27286. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27287. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27289. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27290. removePhysicsBody(impostor: PhysicsImpostor): void;
  27291. generateJoint(joint: PhysicsImpostorJoint): void;
  27292. removeJoint(joint: PhysicsImpostorJoint): void;
  27293. isSupported(): boolean;
  27294. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27295. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27296. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27297. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27298. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27299. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27300. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27301. getBodyMass(impostor: PhysicsImpostor): number;
  27302. getBodyFriction(impostor: PhysicsImpostor): number;
  27303. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27304. getBodyRestitution(impostor: PhysicsImpostor): number;
  27305. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27306. getBodyPressure?(impostor: PhysicsImpostor): number;
  27307. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27308. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27309. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27310. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27311. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27312. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27313. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27314. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27315. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27316. sleepBody(impostor: PhysicsImpostor): void;
  27317. wakeUpBody(impostor: PhysicsImpostor): void;
  27318. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27319. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27320. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27321. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27322. getRadius(impostor: PhysicsImpostor): number;
  27323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27324. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27325. dispose(): void;
  27326. }
  27327. /**
  27328. * Interface used to define a physics engine
  27329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27330. */
  27331. export interface IPhysicsEngine {
  27332. /**
  27333. * Gets the gravity vector used by the simulation
  27334. */
  27335. gravity: Vector3;
  27336. /**
  27337. * Sets the gravity vector used by the simulation
  27338. * @param gravity defines the gravity vector to use
  27339. */
  27340. setGravity(gravity: Vector3): void;
  27341. /**
  27342. * Set the time step of the physics engine.
  27343. * Default is 1/60.
  27344. * To slow it down, enter 1/600 for example.
  27345. * To speed it up, 1/30
  27346. * @param newTimeStep the new timestep to apply to this world.
  27347. */
  27348. setTimeStep(newTimeStep: number): void;
  27349. /**
  27350. * Get the time step of the physics engine.
  27351. * @returns the current time step
  27352. */
  27353. getTimeStep(): number;
  27354. /**
  27355. * Set the sub time step of the physics engine.
  27356. * Default is 0 meaning there is no sub steps
  27357. * To increase physics resolution precision, set a small value (like 1 ms)
  27358. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27359. */
  27360. setSubTimeStep(subTimeStep: number): void;
  27361. /**
  27362. * Get the sub time step of the physics engine.
  27363. * @returns the current sub time step
  27364. */
  27365. getSubTimeStep(): number;
  27366. /**
  27367. * Release all resources
  27368. */
  27369. dispose(): void;
  27370. /**
  27371. * Gets the name of the current physics plugin
  27372. * @returns the name of the plugin
  27373. */
  27374. getPhysicsPluginName(): string;
  27375. /**
  27376. * Adding a new impostor for the impostor tracking.
  27377. * This will be done by the impostor itself.
  27378. * @param impostor the impostor to add
  27379. */
  27380. addImpostor(impostor: PhysicsImpostor): void;
  27381. /**
  27382. * Remove an impostor from the engine.
  27383. * This impostor and its mesh will not longer be updated by the physics engine.
  27384. * @param impostor the impostor to remove
  27385. */
  27386. removeImpostor(impostor: PhysicsImpostor): void;
  27387. /**
  27388. * Add a joint to the physics engine
  27389. * @param mainImpostor defines the main impostor to which the joint is added.
  27390. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27391. * @param joint defines the joint that will connect both impostors.
  27392. */
  27393. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27394. /**
  27395. * Removes a joint from the simulation
  27396. * @param mainImpostor defines the impostor used with the joint
  27397. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27398. * @param joint defines the joint to remove
  27399. */
  27400. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27401. /**
  27402. * Gets the current plugin used to run the simulation
  27403. * @returns current plugin
  27404. */
  27405. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27406. /**
  27407. * Gets the list of physic impostors
  27408. * @returns an array of PhysicsImpostor
  27409. */
  27410. getImpostors(): Array<PhysicsImpostor>;
  27411. /**
  27412. * Gets the impostor for a physics enabled object
  27413. * @param object defines the object impersonated by the impostor
  27414. * @returns the PhysicsImpostor or null if not found
  27415. */
  27416. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27417. /**
  27418. * Gets the impostor for a physics body object
  27419. * @param body defines physics body used by the impostor
  27420. * @returns the PhysicsImpostor or null if not found
  27421. */
  27422. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27423. /**
  27424. * Does a raycast in the physics world
  27425. * @param from when should the ray start?
  27426. * @param to when should the ray end?
  27427. * @returns PhysicsRaycastResult
  27428. */
  27429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27430. /**
  27431. * Called by the scene. No need to call it.
  27432. * @param delta defines the timespam between frames
  27433. */
  27434. _step(delta: number): void;
  27435. }
  27436. }
  27437. declare module BABYLON {
  27438. /**
  27439. * The interface for the physics imposter parameters
  27440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27441. */
  27442. export interface PhysicsImpostorParameters {
  27443. /**
  27444. * The mass of the physics imposter
  27445. */
  27446. mass: number;
  27447. /**
  27448. * The friction of the physics imposter
  27449. */
  27450. friction?: number;
  27451. /**
  27452. * The coefficient of restitution of the physics imposter
  27453. */
  27454. restitution?: number;
  27455. /**
  27456. * The native options of the physics imposter
  27457. */
  27458. nativeOptions?: any;
  27459. /**
  27460. * Specifies if the parent should be ignored
  27461. */
  27462. ignoreParent?: boolean;
  27463. /**
  27464. * Specifies if bi-directional transformations should be disabled
  27465. */
  27466. disableBidirectionalTransformation?: boolean;
  27467. /**
  27468. * The pressure inside the physics imposter, soft object only
  27469. */
  27470. pressure?: number;
  27471. /**
  27472. * The stiffness the physics imposter, soft object only
  27473. */
  27474. stiffness?: number;
  27475. /**
  27476. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27477. */
  27478. velocityIterations?: number;
  27479. /**
  27480. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27481. */
  27482. positionIterations?: number;
  27483. /**
  27484. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27485. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27486. * Add to fix multiple points
  27487. */
  27488. fixedPoints?: number;
  27489. /**
  27490. * The collision margin around a soft object
  27491. */
  27492. margin?: number;
  27493. /**
  27494. * The collision margin around a soft object
  27495. */
  27496. damping?: number;
  27497. /**
  27498. * The path for a rope based on an extrusion
  27499. */
  27500. path?: any;
  27501. /**
  27502. * The shape of an extrusion used for a rope based on an extrusion
  27503. */
  27504. shape?: any;
  27505. }
  27506. /**
  27507. * Interface for a physics-enabled object
  27508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27509. */
  27510. export interface IPhysicsEnabledObject {
  27511. /**
  27512. * The position of the physics-enabled object
  27513. */
  27514. position: Vector3;
  27515. /**
  27516. * The rotation of the physics-enabled object
  27517. */
  27518. rotationQuaternion: Nullable<Quaternion>;
  27519. /**
  27520. * The scale of the physics-enabled object
  27521. */
  27522. scaling: Vector3;
  27523. /**
  27524. * The rotation of the physics-enabled object
  27525. */
  27526. rotation?: Vector3;
  27527. /**
  27528. * The parent of the physics-enabled object
  27529. */
  27530. parent?: any;
  27531. /**
  27532. * The bounding info of the physics-enabled object
  27533. * @returns The bounding info of the physics-enabled object
  27534. */
  27535. getBoundingInfo(): BoundingInfo;
  27536. /**
  27537. * Computes the world matrix
  27538. * @param force Specifies if the world matrix should be computed by force
  27539. * @returns A world matrix
  27540. */
  27541. computeWorldMatrix(force: boolean): Matrix;
  27542. /**
  27543. * Gets the world matrix
  27544. * @returns A world matrix
  27545. */
  27546. getWorldMatrix?(): Matrix;
  27547. /**
  27548. * Gets the child meshes
  27549. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27550. * @returns An array of abstract meshes
  27551. */
  27552. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27553. /**
  27554. * Gets the vertex data
  27555. * @param kind The type of vertex data
  27556. * @returns A nullable array of numbers, or a float32 array
  27557. */
  27558. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27559. /**
  27560. * Gets the indices from the mesh
  27561. * @returns A nullable array of index arrays
  27562. */
  27563. getIndices?(): Nullable<IndicesArray>;
  27564. /**
  27565. * Gets the scene from the mesh
  27566. * @returns the indices array or null
  27567. */
  27568. getScene?(): Scene;
  27569. /**
  27570. * Gets the absolute position from the mesh
  27571. * @returns the absolute position
  27572. */
  27573. getAbsolutePosition(): Vector3;
  27574. /**
  27575. * Gets the absolute pivot point from the mesh
  27576. * @returns the absolute pivot point
  27577. */
  27578. getAbsolutePivotPoint(): Vector3;
  27579. /**
  27580. * Rotates the mesh
  27581. * @param axis The axis of rotation
  27582. * @param amount The amount of rotation
  27583. * @param space The space of the rotation
  27584. * @returns The rotation transform node
  27585. */
  27586. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27587. /**
  27588. * Translates the mesh
  27589. * @param axis The axis of translation
  27590. * @param distance The distance of translation
  27591. * @param space The space of the translation
  27592. * @returns The transform node
  27593. */
  27594. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27595. /**
  27596. * Sets the absolute position of the mesh
  27597. * @param absolutePosition The absolute position of the mesh
  27598. * @returns The transform node
  27599. */
  27600. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27601. /**
  27602. * Gets the class name of the mesh
  27603. * @returns The class name
  27604. */
  27605. getClassName(): string;
  27606. }
  27607. /**
  27608. * Represents a physics imposter
  27609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27610. */
  27611. export class PhysicsImpostor {
  27612. /**
  27613. * The physics-enabled object used as the physics imposter
  27614. */
  27615. object: IPhysicsEnabledObject;
  27616. /**
  27617. * The type of the physics imposter
  27618. */
  27619. type: number;
  27620. private _options;
  27621. private _scene?;
  27622. /**
  27623. * The default object size of the imposter
  27624. */
  27625. static DEFAULT_OBJECT_SIZE: Vector3;
  27626. /**
  27627. * The identity quaternion of the imposter
  27628. */
  27629. static IDENTITY_QUATERNION: Quaternion;
  27630. /** @hidden */
  27631. _pluginData: any;
  27632. private _physicsEngine;
  27633. private _physicsBody;
  27634. private _bodyUpdateRequired;
  27635. private _onBeforePhysicsStepCallbacks;
  27636. private _onAfterPhysicsStepCallbacks;
  27637. /** @hidden */
  27638. _onPhysicsCollideCallbacks: Array<{
  27639. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27640. otherImpostors: Array<PhysicsImpostor>;
  27641. }>;
  27642. private _deltaPosition;
  27643. private _deltaRotation;
  27644. private _deltaRotationConjugated;
  27645. /** @hidden */
  27646. _isFromLine: boolean;
  27647. private _parent;
  27648. private _isDisposed;
  27649. private static _tmpVecs;
  27650. private static _tmpQuat;
  27651. /**
  27652. * Specifies if the physics imposter is disposed
  27653. */
  27654. get isDisposed(): boolean;
  27655. /**
  27656. * Gets the mass of the physics imposter
  27657. */
  27658. get mass(): number;
  27659. set mass(value: number);
  27660. /**
  27661. * Gets the coefficient of friction
  27662. */
  27663. get friction(): number;
  27664. /**
  27665. * Sets the coefficient of friction
  27666. */
  27667. set friction(value: number);
  27668. /**
  27669. * Gets the coefficient of restitution
  27670. */
  27671. get restitution(): number;
  27672. /**
  27673. * Sets the coefficient of restitution
  27674. */
  27675. set restitution(value: number);
  27676. /**
  27677. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27678. */
  27679. get pressure(): number;
  27680. /**
  27681. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27682. */
  27683. set pressure(value: number);
  27684. /**
  27685. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27686. */
  27687. get stiffness(): number;
  27688. /**
  27689. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27690. */
  27691. set stiffness(value: number);
  27692. /**
  27693. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27694. */
  27695. get velocityIterations(): number;
  27696. /**
  27697. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27698. */
  27699. set velocityIterations(value: number);
  27700. /**
  27701. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27702. */
  27703. get positionIterations(): number;
  27704. /**
  27705. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27706. */
  27707. set positionIterations(value: number);
  27708. /**
  27709. * The unique id of the physics imposter
  27710. * set by the physics engine when adding this impostor to the array
  27711. */
  27712. uniqueId: number;
  27713. /**
  27714. * @hidden
  27715. */
  27716. soft: boolean;
  27717. /**
  27718. * @hidden
  27719. */
  27720. segments: number;
  27721. private _joints;
  27722. /**
  27723. * Initializes the physics imposter
  27724. * @param object The physics-enabled object used as the physics imposter
  27725. * @param type The type of the physics imposter
  27726. * @param _options The options for the physics imposter
  27727. * @param _scene The Babylon scene
  27728. */
  27729. constructor(
  27730. /**
  27731. * The physics-enabled object used as the physics imposter
  27732. */
  27733. object: IPhysicsEnabledObject,
  27734. /**
  27735. * The type of the physics imposter
  27736. */
  27737. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27738. /**
  27739. * This function will completly initialize this impostor.
  27740. * It will create a new body - but only if this mesh has no parent.
  27741. * If it has, this impostor will not be used other than to define the impostor
  27742. * of the child mesh.
  27743. * @hidden
  27744. */
  27745. _init(): void;
  27746. private _getPhysicsParent;
  27747. /**
  27748. * Should a new body be generated.
  27749. * @returns boolean specifying if body initialization is required
  27750. */
  27751. isBodyInitRequired(): boolean;
  27752. /**
  27753. * Sets the updated scaling
  27754. * @param updated Specifies if the scaling is updated
  27755. */
  27756. setScalingUpdated(): void;
  27757. /**
  27758. * Force a regeneration of this or the parent's impostor's body.
  27759. * Use under cautious - This will remove all joints already implemented.
  27760. */
  27761. forceUpdate(): void;
  27762. /**
  27763. * Gets the body that holds this impostor. Either its own, or its parent.
  27764. */
  27765. get physicsBody(): any;
  27766. /**
  27767. * Get the parent of the physics imposter
  27768. * @returns Physics imposter or null
  27769. */
  27770. get parent(): Nullable<PhysicsImpostor>;
  27771. /**
  27772. * Sets the parent of the physics imposter
  27773. */
  27774. set parent(value: Nullable<PhysicsImpostor>);
  27775. /**
  27776. * Set the physics body. Used mainly by the physics engine/plugin
  27777. */
  27778. set physicsBody(physicsBody: any);
  27779. /**
  27780. * Resets the update flags
  27781. */
  27782. resetUpdateFlags(): void;
  27783. /**
  27784. * Gets the object extend size
  27785. * @returns the object extend size
  27786. */
  27787. getObjectExtendSize(): Vector3;
  27788. /**
  27789. * Gets the object center
  27790. * @returns The object center
  27791. */
  27792. getObjectCenter(): Vector3;
  27793. /**
  27794. * Get a specific parameter from the options parameters
  27795. * @param paramName The object parameter name
  27796. * @returns The object parameter
  27797. */
  27798. getParam(paramName: string): any;
  27799. /**
  27800. * Sets a specific parameter in the options given to the physics plugin
  27801. * @param paramName The parameter name
  27802. * @param value The value of the parameter
  27803. */
  27804. setParam(paramName: string, value: number): void;
  27805. /**
  27806. * Specifically change the body's mass option. Won't recreate the physics body object
  27807. * @param mass The mass of the physics imposter
  27808. */
  27809. setMass(mass: number): void;
  27810. /**
  27811. * Gets the linear velocity
  27812. * @returns linear velocity or null
  27813. */
  27814. getLinearVelocity(): Nullable<Vector3>;
  27815. /**
  27816. * Sets the linear velocity
  27817. * @param velocity linear velocity or null
  27818. */
  27819. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27820. /**
  27821. * Gets the angular velocity
  27822. * @returns angular velocity or null
  27823. */
  27824. getAngularVelocity(): Nullable<Vector3>;
  27825. /**
  27826. * Sets the angular velocity
  27827. * @param velocity The velocity or null
  27828. */
  27829. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27830. /**
  27831. * Execute a function with the physics plugin native code
  27832. * Provide a function the will have two variables - the world object and the physics body object
  27833. * @param func The function to execute with the physics plugin native code
  27834. */
  27835. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27836. /**
  27837. * Register a function that will be executed before the physics world is stepping forward
  27838. * @param func The function to execute before the physics world is stepped forward
  27839. */
  27840. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Unregister a function that will be executed before the physics world is stepping forward
  27843. * @param func The function to execute before the physics world is stepped forward
  27844. */
  27845. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * Register a function that will be executed after the physics step
  27848. * @param func The function to execute after physics step
  27849. */
  27850. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27851. /**
  27852. * Unregisters a function that will be executed after the physics step
  27853. * @param func The function to execute after physics step
  27854. */
  27855. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27856. /**
  27857. * register a function that will be executed when this impostor collides against a different body
  27858. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27859. * @param func Callback that is executed on collision
  27860. */
  27861. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27862. /**
  27863. * Unregisters the physics imposter on contact
  27864. * @param collideAgainst The physics object to collide against
  27865. * @param func Callback to execute on collision
  27866. */
  27867. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27868. private _tmpQuat;
  27869. private _tmpQuat2;
  27870. /**
  27871. * Get the parent rotation
  27872. * @returns The parent rotation
  27873. */
  27874. getParentsRotation(): Quaternion;
  27875. /**
  27876. * this function is executed by the physics engine.
  27877. */
  27878. beforeStep: () => void;
  27879. /**
  27880. * this function is executed by the physics engine
  27881. */
  27882. afterStep: () => void;
  27883. /**
  27884. * Legacy collision detection event support
  27885. */
  27886. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27887. /**
  27888. * event and body object due to cannon's event-based architecture.
  27889. */
  27890. onCollide: (e: {
  27891. body: any;
  27892. }) => void;
  27893. /**
  27894. * Apply a force
  27895. * @param force The force to apply
  27896. * @param contactPoint The contact point for the force
  27897. * @returns The physics imposter
  27898. */
  27899. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27900. /**
  27901. * Apply an impulse
  27902. * @param force The impulse force
  27903. * @param contactPoint The contact point for the impulse force
  27904. * @returns The physics imposter
  27905. */
  27906. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27907. /**
  27908. * A help function to create a joint
  27909. * @param otherImpostor A physics imposter used to create a joint
  27910. * @param jointType The type of joint
  27911. * @param jointData The data for the joint
  27912. * @returns The physics imposter
  27913. */
  27914. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27915. /**
  27916. * Add a joint to this impostor with a different impostor
  27917. * @param otherImpostor A physics imposter used to add a joint
  27918. * @param joint The joint to add
  27919. * @returns The physics imposter
  27920. */
  27921. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27922. /**
  27923. * Add an anchor to a cloth impostor
  27924. * @param otherImpostor rigid impostor to anchor to
  27925. * @param width ratio across width from 0 to 1
  27926. * @param height ratio up height from 0 to 1
  27927. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27928. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27929. * @returns impostor the soft imposter
  27930. */
  27931. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27932. /**
  27933. * Add a hook to a rope impostor
  27934. * @param otherImpostor rigid impostor to anchor to
  27935. * @param length ratio across rope from 0 to 1
  27936. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27937. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27938. * @returns impostor the rope imposter
  27939. */
  27940. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27941. /**
  27942. * Will keep this body still, in a sleep mode.
  27943. * @returns the physics imposter
  27944. */
  27945. sleep(): PhysicsImpostor;
  27946. /**
  27947. * Wake the body up.
  27948. * @returns The physics imposter
  27949. */
  27950. wakeUp(): PhysicsImpostor;
  27951. /**
  27952. * Clones the physics imposter
  27953. * @param newObject The physics imposter clones to this physics-enabled object
  27954. * @returns A nullable physics imposter
  27955. */
  27956. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27957. /**
  27958. * Disposes the physics imposter
  27959. */
  27960. dispose(): void;
  27961. /**
  27962. * Sets the delta position
  27963. * @param position The delta position amount
  27964. */
  27965. setDeltaPosition(position: Vector3): void;
  27966. /**
  27967. * Sets the delta rotation
  27968. * @param rotation The delta rotation amount
  27969. */
  27970. setDeltaRotation(rotation: Quaternion): void;
  27971. /**
  27972. * Gets the box size of the physics imposter and stores the result in the input parameter
  27973. * @param result Stores the box size
  27974. * @returns The physics imposter
  27975. */
  27976. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27977. /**
  27978. * Gets the radius of the physics imposter
  27979. * @returns Radius of the physics imposter
  27980. */
  27981. getRadius(): number;
  27982. /**
  27983. * Sync a bone with this impostor
  27984. * @param bone The bone to sync to the impostor.
  27985. * @param boneMesh The mesh that the bone is influencing.
  27986. * @param jointPivot The pivot of the joint / bone in local space.
  27987. * @param distToJoint Optional distance from the impostor to the joint.
  27988. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27989. */
  27990. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27991. /**
  27992. * Sync impostor to a bone
  27993. * @param bone The bone that the impostor will be synced to.
  27994. * @param boneMesh The mesh that the bone is influencing.
  27995. * @param jointPivot The pivot of the joint / bone in local space.
  27996. * @param distToJoint Optional distance from the impostor to the joint.
  27997. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27998. * @param boneAxis Optional vector3 axis the bone is aligned with
  27999. */
  28000. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28001. /**
  28002. * No-Imposter type
  28003. */
  28004. static NoImpostor: number;
  28005. /**
  28006. * Sphere-Imposter type
  28007. */
  28008. static SphereImpostor: number;
  28009. /**
  28010. * Box-Imposter type
  28011. */
  28012. static BoxImpostor: number;
  28013. /**
  28014. * Plane-Imposter type
  28015. */
  28016. static PlaneImpostor: number;
  28017. /**
  28018. * Mesh-imposter type
  28019. */
  28020. static MeshImpostor: number;
  28021. /**
  28022. * Capsule-Impostor type (Ammo.js plugin only)
  28023. */
  28024. static CapsuleImpostor: number;
  28025. /**
  28026. * Cylinder-Imposter type
  28027. */
  28028. static CylinderImpostor: number;
  28029. /**
  28030. * Particle-Imposter type
  28031. */
  28032. static ParticleImpostor: number;
  28033. /**
  28034. * Heightmap-Imposter type
  28035. */
  28036. static HeightmapImpostor: number;
  28037. /**
  28038. * ConvexHull-Impostor type (Ammo.js plugin only)
  28039. */
  28040. static ConvexHullImpostor: number;
  28041. /**
  28042. * Custom-Imposter type (Ammo.js plugin only)
  28043. */
  28044. static CustomImpostor: number;
  28045. /**
  28046. * Rope-Imposter type
  28047. */
  28048. static RopeImpostor: number;
  28049. /**
  28050. * Cloth-Imposter type
  28051. */
  28052. static ClothImpostor: number;
  28053. /**
  28054. * Softbody-Imposter type
  28055. */
  28056. static SoftbodyImpostor: number;
  28057. }
  28058. }
  28059. declare module BABYLON {
  28060. /**
  28061. * @hidden
  28062. **/
  28063. export class _CreationDataStorage {
  28064. closePath?: boolean;
  28065. closeArray?: boolean;
  28066. idx: number[];
  28067. dashSize: number;
  28068. gapSize: number;
  28069. path3D: Path3D;
  28070. pathArray: Vector3[][];
  28071. arc: number;
  28072. radius: number;
  28073. cap: number;
  28074. tessellation: number;
  28075. }
  28076. /**
  28077. * @hidden
  28078. **/
  28079. class _InstanceDataStorage {
  28080. visibleInstances: any;
  28081. batchCache: _InstancesBatch;
  28082. instancesBufferSize: number;
  28083. instancesBuffer: Nullable<Buffer>;
  28084. instancesData: Float32Array;
  28085. overridenInstanceCount: number;
  28086. isFrozen: boolean;
  28087. previousBatch: Nullable<_InstancesBatch>;
  28088. hardwareInstancedRendering: boolean;
  28089. sideOrientation: number;
  28090. manualUpdate: boolean;
  28091. }
  28092. /**
  28093. * @hidden
  28094. **/
  28095. export class _InstancesBatch {
  28096. mustReturn: boolean;
  28097. visibleInstances: Nullable<InstancedMesh[]>[];
  28098. renderSelf: boolean[];
  28099. hardwareInstancedRendering: boolean[];
  28100. }
  28101. /**
  28102. * @hidden
  28103. **/
  28104. class _ThinInstanceDataStorage {
  28105. instancesCount: number;
  28106. matrixBuffer: Nullable<Buffer>;
  28107. matrixBufferSize: number;
  28108. matrixData: Nullable<Float32Array>;
  28109. boundingVectors: Array<Vector3>;
  28110. worldMatrices: Nullable<Matrix[]>;
  28111. }
  28112. /**
  28113. * Class used to represent renderable models
  28114. */
  28115. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28116. /**
  28117. * Mesh side orientation : usually the external or front surface
  28118. */
  28119. static readonly FRONTSIDE: number;
  28120. /**
  28121. * Mesh side orientation : usually the internal or back surface
  28122. */
  28123. static readonly BACKSIDE: number;
  28124. /**
  28125. * Mesh side orientation : both internal and external or front and back surfaces
  28126. */
  28127. static readonly DOUBLESIDE: number;
  28128. /**
  28129. * Mesh side orientation : by default, `FRONTSIDE`
  28130. */
  28131. static readonly DEFAULTSIDE: number;
  28132. /**
  28133. * Mesh cap setting : no cap
  28134. */
  28135. static readonly NO_CAP: number;
  28136. /**
  28137. * Mesh cap setting : one cap at the beginning of the mesh
  28138. */
  28139. static readonly CAP_START: number;
  28140. /**
  28141. * Mesh cap setting : one cap at the end of the mesh
  28142. */
  28143. static readonly CAP_END: number;
  28144. /**
  28145. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28146. */
  28147. static readonly CAP_ALL: number;
  28148. /**
  28149. * Mesh pattern setting : no flip or rotate
  28150. */
  28151. static readonly NO_FLIP: number;
  28152. /**
  28153. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28154. */
  28155. static readonly FLIP_TILE: number;
  28156. /**
  28157. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28158. */
  28159. static readonly ROTATE_TILE: number;
  28160. /**
  28161. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28162. */
  28163. static readonly FLIP_ROW: number;
  28164. /**
  28165. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28166. */
  28167. static readonly ROTATE_ROW: number;
  28168. /**
  28169. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28170. */
  28171. static readonly FLIP_N_ROTATE_TILE: number;
  28172. /**
  28173. * Mesh pattern setting : rotate pattern and rotate
  28174. */
  28175. static readonly FLIP_N_ROTATE_ROW: number;
  28176. /**
  28177. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28178. */
  28179. static readonly CENTER: number;
  28180. /**
  28181. * Mesh tile positioning : part tiles on left
  28182. */
  28183. static readonly LEFT: number;
  28184. /**
  28185. * Mesh tile positioning : part tiles on right
  28186. */
  28187. static readonly RIGHT: number;
  28188. /**
  28189. * Mesh tile positioning : part tiles on top
  28190. */
  28191. static readonly TOP: number;
  28192. /**
  28193. * Mesh tile positioning : part tiles on bottom
  28194. */
  28195. static readonly BOTTOM: number;
  28196. /**
  28197. * Gets the default side orientation.
  28198. * @param orientation the orientation to value to attempt to get
  28199. * @returns the default orientation
  28200. * @hidden
  28201. */
  28202. static _GetDefaultSideOrientation(orientation?: number): number;
  28203. private _internalMeshDataInfo;
  28204. get computeBonesUsingShaders(): boolean;
  28205. set computeBonesUsingShaders(value: boolean);
  28206. /**
  28207. * An event triggered before rendering the mesh
  28208. */
  28209. get onBeforeRenderObservable(): Observable<Mesh>;
  28210. /**
  28211. * An event triggered before binding the mesh
  28212. */
  28213. get onBeforeBindObservable(): Observable<Mesh>;
  28214. /**
  28215. * An event triggered after rendering the mesh
  28216. */
  28217. get onAfterRenderObservable(): Observable<Mesh>;
  28218. /**
  28219. * An event triggered before drawing the mesh
  28220. */
  28221. get onBeforeDrawObservable(): Observable<Mesh>;
  28222. private _onBeforeDrawObserver;
  28223. /**
  28224. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28225. */
  28226. set onBeforeDraw(callback: () => void);
  28227. get hasInstances(): boolean;
  28228. get hasThinInstances(): boolean;
  28229. /**
  28230. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28231. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28232. */
  28233. delayLoadState: number;
  28234. /**
  28235. * Gets the list of instances created from this mesh
  28236. * it is not supposed to be modified manually.
  28237. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28238. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28239. */
  28240. instances: InstancedMesh[];
  28241. /**
  28242. * Gets the file containing delay loading data for this mesh
  28243. */
  28244. delayLoadingFile: string;
  28245. /** @hidden */
  28246. _binaryInfo: any;
  28247. /**
  28248. * User defined function used to change how LOD level selection is done
  28249. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28250. */
  28251. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28252. /**
  28253. * Gets or sets the morph target manager
  28254. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28255. */
  28256. get morphTargetManager(): Nullable<MorphTargetManager>;
  28257. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28258. /** @hidden */
  28259. _creationDataStorage: Nullable<_CreationDataStorage>;
  28260. /** @hidden */
  28261. _geometry: Nullable<Geometry>;
  28262. /** @hidden */
  28263. _delayInfo: Array<string>;
  28264. /** @hidden */
  28265. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28266. /** @hidden */
  28267. _instanceDataStorage: _InstanceDataStorage;
  28268. /** @hidden */
  28269. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28270. private _effectiveMaterial;
  28271. /** @hidden */
  28272. _shouldGenerateFlatShading: boolean;
  28273. /** @hidden */
  28274. _originalBuilderSideOrientation: number;
  28275. /**
  28276. * Use this property to change the original side orientation defined at construction time
  28277. */
  28278. overrideMaterialSideOrientation: Nullable<number>;
  28279. /**
  28280. * Gets the source mesh (the one used to clone this one from)
  28281. */
  28282. get source(): Nullable<Mesh>;
  28283. /**
  28284. * Gets the list of clones of this mesh
  28285. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28286. * Note that useClonedMeshMap=true is the default setting
  28287. */
  28288. get cloneMeshMap(): Nullable<{
  28289. [id: string]: Mesh | undefined;
  28290. }>;
  28291. /**
  28292. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28293. */
  28294. get isUnIndexed(): boolean;
  28295. set isUnIndexed(value: boolean);
  28296. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28297. get worldMatrixInstancedBuffer(): Float32Array;
  28298. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28299. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28300. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28301. /**
  28302. * @constructor
  28303. * @param name The value used by scene.getMeshByName() to do a lookup.
  28304. * @param scene The scene to add this mesh to.
  28305. * @param parent The parent of this mesh, if it has one
  28306. * @param source An optional Mesh from which geometry is shared, cloned.
  28307. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28308. * When false, achieved by calling a clone(), also passing False.
  28309. * This will make creation of children, recursive.
  28310. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28311. */
  28312. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28313. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28314. doNotInstantiate: boolean;
  28315. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28316. /**
  28317. * Gets the class name
  28318. * @returns the string "Mesh".
  28319. */
  28320. getClassName(): string;
  28321. /** @hidden */
  28322. get _isMesh(): boolean;
  28323. /**
  28324. * Returns a description of this mesh
  28325. * @param fullDetails define if full details about this mesh must be used
  28326. * @returns a descriptive string representing this mesh
  28327. */
  28328. toString(fullDetails?: boolean): string;
  28329. /** @hidden */
  28330. _unBindEffect(): void;
  28331. /**
  28332. * Gets a boolean indicating if this mesh has LOD
  28333. */
  28334. get hasLODLevels(): boolean;
  28335. /**
  28336. * Gets the list of MeshLODLevel associated with the current mesh
  28337. * @returns an array of MeshLODLevel
  28338. */
  28339. getLODLevels(): MeshLODLevel[];
  28340. private _sortLODLevels;
  28341. /**
  28342. * Add a mesh as LOD level triggered at the given distance.
  28343. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28344. * @param distance The distance from the center of the object to show this level
  28345. * @param mesh The mesh to be added as LOD level (can be null)
  28346. * @return This mesh (for chaining)
  28347. */
  28348. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28349. /**
  28350. * Returns the LOD level mesh at the passed distance or null if not found.
  28351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28352. * @param distance The distance from the center of the object to show this level
  28353. * @returns a Mesh or `null`
  28354. */
  28355. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28356. /**
  28357. * Remove a mesh from the LOD array
  28358. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28359. * @param mesh defines the mesh to be removed
  28360. * @return This mesh (for chaining)
  28361. */
  28362. removeLODLevel(mesh: Mesh): Mesh;
  28363. /**
  28364. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28365. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28366. * @param camera defines the camera to use to compute distance
  28367. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28368. * @return This mesh (for chaining)
  28369. */
  28370. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28371. /**
  28372. * Gets the mesh internal Geometry object
  28373. */
  28374. get geometry(): Nullable<Geometry>;
  28375. /**
  28376. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28377. * @returns the total number of vertices
  28378. */
  28379. getTotalVertices(): number;
  28380. /**
  28381. * Returns the content of an associated vertex buffer
  28382. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28383. * - VertexBuffer.PositionKind
  28384. * - VertexBuffer.UVKind
  28385. * - VertexBuffer.UV2Kind
  28386. * - VertexBuffer.UV3Kind
  28387. * - VertexBuffer.UV4Kind
  28388. * - VertexBuffer.UV5Kind
  28389. * - VertexBuffer.UV6Kind
  28390. * - VertexBuffer.ColorKind
  28391. * - VertexBuffer.MatricesIndicesKind
  28392. * - VertexBuffer.MatricesIndicesExtraKind
  28393. * - VertexBuffer.MatricesWeightsKind
  28394. * - VertexBuffer.MatricesWeightsExtraKind
  28395. * @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
  28396. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28397. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28398. */
  28399. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28400. /**
  28401. * Returns the mesh VertexBuffer object from the requested `kind`
  28402. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28403. * - VertexBuffer.PositionKind
  28404. * - VertexBuffer.NormalKind
  28405. * - VertexBuffer.UVKind
  28406. * - VertexBuffer.UV2Kind
  28407. * - VertexBuffer.UV3Kind
  28408. * - VertexBuffer.UV4Kind
  28409. * - VertexBuffer.UV5Kind
  28410. * - VertexBuffer.UV6Kind
  28411. * - VertexBuffer.ColorKind
  28412. * - VertexBuffer.MatricesIndicesKind
  28413. * - VertexBuffer.MatricesIndicesExtraKind
  28414. * - VertexBuffer.MatricesWeightsKind
  28415. * - VertexBuffer.MatricesWeightsExtraKind
  28416. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28417. */
  28418. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28419. /**
  28420. * Tests if a specific vertex buffer is associated with this mesh
  28421. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28422. * - VertexBuffer.PositionKind
  28423. * - VertexBuffer.NormalKind
  28424. * - VertexBuffer.UVKind
  28425. * - VertexBuffer.UV2Kind
  28426. * - VertexBuffer.UV3Kind
  28427. * - VertexBuffer.UV4Kind
  28428. * - VertexBuffer.UV5Kind
  28429. * - VertexBuffer.UV6Kind
  28430. * - VertexBuffer.ColorKind
  28431. * - VertexBuffer.MatricesIndicesKind
  28432. * - VertexBuffer.MatricesIndicesExtraKind
  28433. * - VertexBuffer.MatricesWeightsKind
  28434. * - VertexBuffer.MatricesWeightsExtraKind
  28435. * @returns a boolean
  28436. */
  28437. isVerticesDataPresent(kind: string): boolean;
  28438. /**
  28439. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28440. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28441. * - VertexBuffer.PositionKind
  28442. * - VertexBuffer.UVKind
  28443. * - VertexBuffer.UV2Kind
  28444. * - VertexBuffer.UV3Kind
  28445. * - VertexBuffer.UV4Kind
  28446. * - VertexBuffer.UV5Kind
  28447. * - VertexBuffer.UV6Kind
  28448. * - VertexBuffer.ColorKind
  28449. * - VertexBuffer.MatricesIndicesKind
  28450. * - VertexBuffer.MatricesIndicesExtraKind
  28451. * - VertexBuffer.MatricesWeightsKind
  28452. * - VertexBuffer.MatricesWeightsExtraKind
  28453. * @returns a boolean
  28454. */
  28455. isVertexBufferUpdatable(kind: string): boolean;
  28456. /**
  28457. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28458. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28459. * - VertexBuffer.PositionKind
  28460. * - VertexBuffer.NormalKind
  28461. * - VertexBuffer.UVKind
  28462. * - VertexBuffer.UV2Kind
  28463. * - VertexBuffer.UV3Kind
  28464. * - VertexBuffer.UV4Kind
  28465. * - VertexBuffer.UV5Kind
  28466. * - VertexBuffer.UV6Kind
  28467. * - VertexBuffer.ColorKind
  28468. * - VertexBuffer.MatricesIndicesKind
  28469. * - VertexBuffer.MatricesIndicesExtraKind
  28470. * - VertexBuffer.MatricesWeightsKind
  28471. * - VertexBuffer.MatricesWeightsExtraKind
  28472. * @returns an array of strings
  28473. */
  28474. getVerticesDataKinds(): string[];
  28475. /**
  28476. * Returns a positive integer : the total number of indices in this mesh geometry.
  28477. * @returns the numner of indices or zero if the mesh has no geometry.
  28478. */
  28479. getTotalIndices(): number;
  28480. /**
  28481. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28482. * @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.
  28483. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28484. * @returns the indices array or an empty array if the mesh has no geometry
  28485. */
  28486. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28487. get isBlocked(): boolean;
  28488. /**
  28489. * Determine if the current mesh is ready to be rendered
  28490. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28491. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28492. * @returns true if all associated assets are ready (material, textures, shaders)
  28493. */
  28494. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28495. /**
  28496. * 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.
  28497. */
  28498. get areNormalsFrozen(): boolean;
  28499. /**
  28500. * 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.
  28501. * @returns the current mesh
  28502. */
  28503. freezeNormals(): Mesh;
  28504. /**
  28505. * 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
  28506. * @returns the current mesh
  28507. */
  28508. unfreezeNormals(): Mesh;
  28509. /**
  28510. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28511. */
  28512. set overridenInstanceCount(count: number);
  28513. /** @hidden */
  28514. _preActivate(): Mesh;
  28515. /** @hidden */
  28516. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28517. /** @hidden */
  28518. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28519. protected _afterComputeWorldMatrix(): void;
  28520. /** @hidden */
  28521. _postActivate(): void;
  28522. /**
  28523. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28524. * This means the mesh underlying bounding box and sphere are recomputed.
  28525. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28526. * @returns the current mesh
  28527. */
  28528. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28529. /** @hidden */
  28530. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28531. /**
  28532. * This function will subdivide the mesh into multiple submeshes
  28533. * @param count defines the expected number of submeshes
  28534. */
  28535. subdivide(count: number): void;
  28536. /**
  28537. * Copy a FloatArray into a specific associated vertex buffer
  28538. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28539. * - VertexBuffer.PositionKind
  28540. * - VertexBuffer.UVKind
  28541. * - VertexBuffer.UV2Kind
  28542. * - VertexBuffer.UV3Kind
  28543. * - VertexBuffer.UV4Kind
  28544. * - VertexBuffer.UV5Kind
  28545. * - VertexBuffer.UV6Kind
  28546. * - VertexBuffer.ColorKind
  28547. * - VertexBuffer.MatricesIndicesKind
  28548. * - VertexBuffer.MatricesIndicesExtraKind
  28549. * - VertexBuffer.MatricesWeightsKind
  28550. * - VertexBuffer.MatricesWeightsExtraKind
  28551. * @param data defines the data source
  28552. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28553. * @param stride defines the data stride size (can be null)
  28554. * @returns the current mesh
  28555. */
  28556. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28557. /**
  28558. * Delete a vertex buffer associated with this mesh
  28559. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28560. * - VertexBuffer.PositionKind
  28561. * - VertexBuffer.UVKind
  28562. * - VertexBuffer.UV2Kind
  28563. * - VertexBuffer.UV3Kind
  28564. * - VertexBuffer.UV4Kind
  28565. * - VertexBuffer.UV5Kind
  28566. * - VertexBuffer.UV6Kind
  28567. * - VertexBuffer.ColorKind
  28568. * - VertexBuffer.MatricesIndicesKind
  28569. * - VertexBuffer.MatricesIndicesExtraKind
  28570. * - VertexBuffer.MatricesWeightsKind
  28571. * - VertexBuffer.MatricesWeightsExtraKind
  28572. */
  28573. removeVerticesData(kind: string): void;
  28574. /**
  28575. * Flags an associated vertex buffer as updatable
  28576. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28577. * - VertexBuffer.PositionKind
  28578. * - VertexBuffer.UVKind
  28579. * - VertexBuffer.UV2Kind
  28580. * - VertexBuffer.UV3Kind
  28581. * - VertexBuffer.UV4Kind
  28582. * - VertexBuffer.UV5Kind
  28583. * - VertexBuffer.UV6Kind
  28584. * - VertexBuffer.ColorKind
  28585. * - VertexBuffer.MatricesIndicesKind
  28586. * - VertexBuffer.MatricesIndicesExtraKind
  28587. * - VertexBuffer.MatricesWeightsKind
  28588. * - VertexBuffer.MatricesWeightsExtraKind
  28589. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28590. */
  28591. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28592. /**
  28593. * Sets the mesh global Vertex Buffer
  28594. * @param buffer defines the buffer to use
  28595. * @returns the current mesh
  28596. */
  28597. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28598. /**
  28599. * Update a specific associated vertex buffer
  28600. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28601. * - VertexBuffer.PositionKind
  28602. * - VertexBuffer.UVKind
  28603. * - VertexBuffer.UV2Kind
  28604. * - VertexBuffer.UV3Kind
  28605. * - VertexBuffer.UV4Kind
  28606. * - VertexBuffer.UV5Kind
  28607. * - VertexBuffer.UV6Kind
  28608. * - VertexBuffer.ColorKind
  28609. * - VertexBuffer.MatricesIndicesKind
  28610. * - VertexBuffer.MatricesIndicesExtraKind
  28611. * - VertexBuffer.MatricesWeightsKind
  28612. * - VertexBuffer.MatricesWeightsExtraKind
  28613. * @param data defines the data source
  28614. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28615. * @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)
  28616. * @returns the current mesh
  28617. */
  28618. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28619. /**
  28620. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28621. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28622. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28623. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28624. * @returns the current mesh
  28625. */
  28626. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28627. /**
  28628. * Creates a un-shared specific occurence of the geometry for the mesh.
  28629. * @returns the current mesh
  28630. */
  28631. makeGeometryUnique(): Mesh;
  28632. /**
  28633. * Set the index buffer of this mesh
  28634. * @param indices defines the source data
  28635. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28636. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28637. * @returns the current mesh
  28638. */
  28639. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28640. /**
  28641. * Update the current index buffer
  28642. * @param indices defines the source data
  28643. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28644. * @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)
  28645. * @returns the current mesh
  28646. */
  28647. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28648. /**
  28649. * Invert the geometry to move from a right handed system to a left handed one.
  28650. * @returns the current mesh
  28651. */
  28652. toLeftHanded(): Mesh;
  28653. /** @hidden */
  28654. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28655. /** @hidden */
  28656. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28657. /**
  28658. * Registers for this mesh a javascript function called just before the rendering process
  28659. * @param func defines the function to call before rendering this mesh
  28660. * @returns the current mesh
  28661. */
  28662. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28663. /**
  28664. * Disposes a previously registered javascript function called before the rendering
  28665. * @param func defines the function to remove
  28666. * @returns the current mesh
  28667. */
  28668. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28669. /**
  28670. * Registers for this mesh a javascript function called just after the rendering is complete
  28671. * @param func defines the function to call after rendering this mesh
  28672. * @returns the current mesh
  28673. */
  28674. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28675. /**
  28676. * Disposes a previously registered javascript function called after the rendering.
  28677. * @param func defines the function to remove
  28678. * @returns the current mesh
  28679. */
  28680. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28681. /** @hidden */
  28682. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28683. /** @hidden */
  28684. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28685. /** @hidden */
  28686. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28687. /** @hidden */
  28688. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28689. /** @hidden */
  28690. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28691. /** @hidden */
  28692. _rebuild(): void;
  28693. /** @hidden */
  28694. _freeze(): void;
  28695. /** @hidden */
  28696. _unFreeze(): void;
  28697. /**
  28698. * 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
  28699. * @param subMesh defines the subMesh to render
  28700. * @param enableAlphaMode defines if alpha mode can be changed
  28701. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28702. * @returns the current mesh
  28703. */
  28704. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28705. private _onBeforeDraw;
  28706. /**
  28707. * Renormalize the mesh and patch it up if there are no weights
  28708. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28709. * However in the case of zero weights then we set just a single influence to 1.
  28710. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28711. */
  28712. cleanMatrixWeights(): void;
  28713. private normalizeSkinFourWeights;
  28714. private normalizeSkinWeightsAndExtra;
  28715. /**
  28716. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28717. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28718. * the user know there was an issue with importing the mesh
  28719. * @returns a validation object with skinned, valid and report string
  28720. */
  28721. validateSkinning(): {
  28722. skinned: boolean;
  28723. valid: boolean;
  28724. report: string;
  28725. };
  28726. /** @hidden */
  28727. _checkDelayState(): Mesh;
  28728. private _queueLoad;
  28729. /**
  28730. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28731. * A mesh is in the frustum if its bounding box intersects the frustum
  28732. * @param frustumPlanes defines the frustum to test
  28733. * @returns true if the mesh is in the frustum planes
  28734. */
  28735. isInFrustum(frustumPlanes: Plane[]): boolean;
  28736. /**
  28737. * Sets the mesh material by the material or multiMaterial `id` property
  28738. * @param id is a string identifying the material or the multiMaterial
  28739. * @returns the current mesh
  28740. */
  28741. setMaterialByID(id: string): Mesh;
  28742. /**
  28743. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28744. * @returns an array of IAnimatable
  28745. */
  28746. getAnimatables(): IAnimatable[];
  28747. /**
  28748. * Modifies the mesh geometry according to the passed transformation matrix.
  28749. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28750. * The mesh normals are modified using the same transformation.
  28751. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28752. * @param transform defines the transform matrix to use
  28753. * @see https://doc.babylonjs.com/resources/baking_transformations
  28754. * @returns the current mesh
  28755. */
  28756. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28757. /**
  28758. * Modifies the mesh geometry according to its own current World Matrix.
  28759. * The mesh World Matrix is then reset.
  28760. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28761. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28762. * @see https://doc.babylonjs.com/resources/baking_transformations
  28763. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28764. * @returns the current mesh
  28765. */
  28766. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28767. /** @hidden */
  28768. get _positions(): Nullable<Vector3[]>;
  28769. /** @hidden */
  28770. _resetPointsArrayCache(): Mesh;
  28771. /** @hidden */
  28772. _generatePointsArray(): boolean;
  28773. /**
  28774. * Returns a new Mesh object generated from the current mesh properties.
  28775. * This method must not get confused with createInstance()
  28776. * @param name is a string, the name given to the new mesh
  28777. * @param newParent can be any Node object (default `null`)
  28778. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28779. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28780. * @returns a new mesh
  28781. */
  28782. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28783. /**
  28784. * Releases resources associated with this mesh.
  28785. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28786. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28787. */
  28788. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28789. /** @hidden */
  28790. _disposeInstanceSpecificData(): void;
  28791. /** @hidden */
  28792. _disposeThinInstanceSpecificData(): void;
  28793. /**
  28794. * Modifies the mesh geometry according to a displacement map.
  28795. * 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.
  28796. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28797. * @param url is a string, the URL from the image file is to be downloaded.
  28798. * @param minHeight is the lower limit of the displacement.
  28799. * @param maxHeight is the upper limit of the displacement.
  28800. * @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.
  28801. * @param uvOffset is an optional vector2 used to offset UV.
  28802. * @param uvScale is an optional vector2 used to scale UV.
  28803. * @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.
  28804. * @returns the Mesh.
  28805. */
  28806. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28807. /**
  28808. * Modifies the mesh geometry according to a displacementMap buffer.
  28809. * 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.
  28810. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28811. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28812. * @param heightMapWidth is the width of the buffer image.
  28813. * @param heightMapHeight is the height of the buffer image.
  28814. * @param minHeight is the lower limit of the displacement.
  28815. * @param maxHeight is the upper limit of the displacement.
  28816. * @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.
  28817. * @param uvOffset is an optional vector2 used to offset UV.
  28818. * @param uvScale is an optional vector2 used to scale UV.
  28819. * @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.
  28820. * @returns the Mesh.
  28821. */
  28822. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28823. /**
  28824. * Modify the mesh to get a flat shading rendering.
  28825. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28826. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28827. * @returns current mesh
  28828. */
  28829. convertToFlatShadedMesh(): Mesh;
  28830. /**
  28831. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28832. * In other words, more vertices, no more indices and a single bigger VBO.
  28833. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28834. * @returns current mesh
  28835. */
  28836. convertToUnIndexedMesh(): Mesh;
  28837. /**
  28838. * Inverses facet orientations.
  28839. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28840. * @param flipNormals will also inverts the normals
  28841. * @returns current mesh
  28842. */
  28843. flipFaces(flipNormals?: boolean): Mesh;
  28844. /**
  28845. * Increase the number of facets and hence vertices in a mesh
  28846. * Vertex normals are interpolated from existing vertex normals
  28847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28848. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28849. */
  28850. increaseVertices(numberPerEdge: number): void;
  28851. /**
  28852. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28853. * This will undo any application of covertToFlatShadedMesh
  28854. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28855. */
  28856. forceSharedVertices(): void;
  28857. /** @hidden */
  28858. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28859. /** @hidden */
  28860. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28861. /**
  28862. * Creates a new InstancedMesh object from the mesh model.
  28863. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28864. * @param name defines the name of the new instance
  28865. * @returns a new InstancedMesh
  28866. */
  28867. createInstance(name: string): InstancedMesh;
  28868. /**
  28869. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28870. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28871. * @returns the current mesh
  28872. */
  28873. synchronizeInstances(): Mesh;
  28874. /**
  28875. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28876. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28877. * This should be used together with the simplification to avoid disappearing triangles.
  28878. * @param successCallback an optional success callback to be called after the optimization finished.
  28879. * @returns the current mesh
  28880. */
  28881. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28882. /**
  28883. * Serialize current mesh
  28884. * @param serializationObject defines the object which will receive the serialization data
  28885. */
  28886. serialize(serializationObject: any): void;
  28887. /** @hidden */
  28888. _syncGeometryWithMorphTargetManager(): void;
  28889. /** @hidden */
  28890. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28891. /**
  28892. * Returns a new Mesh object parsed from the source provided.
  28893. * @param parsedMesh is the source
  28894. * @param scene defines the hosting scene
  28895. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28896. * @returns a new Mesh
  28897. */
  28898. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28899. /**
  28900. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28902. * @param name defines the name of the mesh to create
  28903. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28904. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28905. * @param closePath creates a seam between the first and the last points of each path of the path array
  28906. * @param offset is taken in account only if the `pathArray` is containing a single path
  28907. * @param scene defines the hosting scene
  28908. * @param updatable defines if the mesh must be flagged as updatable
  28909. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28910. * @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)
  28911. * @returns a new Mesh
  28912. */
  28913. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28914. /**
  28915. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28916. * @param name defines the name of the mesh to create
  28917. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28918. * @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
  28919. * @param scene defines the hosting scene
  28920. * @param updatable defines if the mesh must be flagged as updatable
  28921. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28922. * @returns a new Mesh
  28923. */
  28924. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28925. /**
  28926. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28927. * @param name defines the name of the mesh to create
  28928. * @param size sets the size (float) of each box side (default 1)
  28929. * @param scene defines the hosting scene
  28930. * @param updatable defines if the mesh must be flagged as updatable
  28931. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28932. * @returns a new Mesh
  28933. */
  28934. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28935. /**
  28936. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28937. * @param name defines the name of the mesh to create
  28938. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28939. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28940. * @param scene defines the hosting scene
  28941. * @param updatable defines if the mesh must be flagged as updatable
  28942. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28943. * @returns a new Mesh
  28944. */
  28945. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28946. /**
  28947. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28948. * @param name defines the name of the mesh to create
  28949. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28950. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28951. * @param scene defines the hosting scene
  28952. * @returns a new Mesh
  28953. */
  28954. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28955. /**
  28956. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28957. * @param name defines the name of the mesh to create
  28958. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28959. * @param diameterTop set the top cap diameter (floats, default 1)
  28960. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28961. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28962. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28963. * @param scene defines the hosting scene
  28964. * @param updatable defines if the mesh must be flagged as updatable
  28965. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28966. * @returns a new Mesh
  28967. */
  28968. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28969. /**
  28970. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28971. * @param name defines the name of the mesh to create
  28972. * @param diameter sets the diameter size (float) of the torus (default 1)
  28973. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28974. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28975. * @param scene defines the hosting scene
  28976. * @param updatable defines if the mesh must be flagged as updatable
  28977. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28978. * @returns a new Mesh
  28979. */
  28980. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28981. /**
  28982. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28983. * @param name defines the name of the mesh to create
  28984. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28985. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28986. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28987. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28988. * @param p the number of windings on X axis (positive integers, default 2)
  28989. * @param q the number of windings on Y axis (positive integers, default 3)
  28990. * @param scene defines the hosting scene
  28991. * @param updatable defines if the mesh must be flagged as updatable
  28992. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28993. * @returns a new Mesh
  28994. */
  28995. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28996. /**
  28997. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28998. * @param name defines the name of the mesh to create
  28999. * @param points is an array successive Vector3
  29000. * @param scene defines the hosting scene
  29001. * @param updatable defines if the mesh must be flagged as updatable
  29002. * @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).
  29003. * @returns a new Mesh
  29004. */
  29005. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29006. /**
  29007. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29008. * @param name defines the name of the mesh to create
  29009. * @param points is an array successive Vector3
  29010. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29011. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29012. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29013. * @param scene defines the hosting scene
  29014. * @param updatable defines if the mesh must be flagged as updatable
  29015. * @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)
  29016. * @returns a new Mesh
  29017. */
  29018. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29019. /**
  29020. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29021. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29022. * 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.
  29023. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29024. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29025. * Remember you can only change the shape positions, not their number when updating a polygon.
  29026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29027. * @param name defines the name of the mesh to create
  29028. * @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
  29029. * @param scene defines the hosting scene
  29030. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29031. * @param updatable defines if the mesh must be flagged as updatable
  29032. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29033. * @param earcutInjection can be used to inject your own earcut reference
  29034. * @returns a new Mesh
  29035. */
  29036. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29037. /**
  29038. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29040. * @param name defines the name of the mesh to create
  29041. * @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
  29042. * @param depth defines the height of extrusion
  29043. * @param scene defines the hosting scene
  29044. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29045. * @param updatable defines if the mesh must be flagged as updatable
  29046. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29047. * @param earcutInjection can be used to inject your own earcut reference
  29048. * @returns a new Mesh
  29049. */
  29050. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29051. /**
  29052. * Creates an extruded shape mesh.
  29053. * 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
  29054. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29056. * @param name defines the name of the mesh to create
  29057. * @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
  29058. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29059. * @param scale is the value to scale the shape
  29060. * @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
  29061. * @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
  29062. * @param scene defines the hosting scene
  29063. * @param updatable defines if the mesh must be flagged as updatable
  29064. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29065. * @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)
  29066. * @returns a new Mesh
  29067. */
  29068. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29069. /**
  29070. * Creates an custom extruded shape mesh.
  29071. * The custom extrusion is a parametric shape.
  29072. * It has no predefined shape. Its final shape will depend on the input parameters.
  29073. * Please consider using the same method from the MeshBuilder class instead
  29074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29075. * @param name defines the name of the mesh to create
  29076. * @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
  29077. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29078. * @param scaleFunction is a custom Javascript function called on each path point
  29079. * @param rotationFunction is a custom Javascript function called on each path point
  29080. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29081. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29082. * @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
  29083. * @param scene defines the hosting scene
  29084. * @param updatable defines if the mesh must be flagged as updatable
  29085. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29086. * @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)
  29087. * @returns a new Mesh
  29088. */
  29089. 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;
  29090. /**
  29091. * Creates lathe mesh.
  29092. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29093. * Please consider using the same method from the MeshBuilder class instead
  29094. * @param name defines the name of the mesh to create
  29095. * @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
  29096. * @param radius is the radius value of the lathe
  29097. * @param tessellation is the side number of the lathe.
  29098. * @param scene defines the hosting scene
  29099. * @param updatable defines if the mesh must be flagged as updatable
  29100. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29101. * @returns a new Mesh
  29102. */
  29103. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29104. /**
  29105. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29106. * @param name defines the name of the mesh to create
  29107. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29108. * @param scene defines the hosting scene
  29109. * @param updatable defines if the mesh must be flagged as updatable
  29110. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29111. * @returns a new Mesh
  29112. */
  29113. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29114. /**
  29115. * Creates a ground mesh.
  29116. * Please consider using the same method from the MeshBuilder class instead
  29117. * @param name defines the name of the mesh to create
  29118. * @param width set the width of the ground
  29119. * @param height set the height of the ground
  29120. * @param subdivisions sets the number of subdivisions per side
  29121. * @param scene defines the hosting scene
  29122. * @param updatable defines if the mesh must be flagged as updatable
  29123. * @returns a new Mesh
  29124. */
  29125. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29126. /**
  29127. * Creates a tiled ground mesh.
  29128. * Please consider using the same method from the MeshBuilder class instead
  29129. * @param name defines the name of the mesh to create
  29130. * @param xmin set the ground minimum X coordinate
  29131. * @param zmin set the ground minimum Y coordinate
  29132. * @param xmax set the ground maximum X coordinate
  29133. * @param zmax set the ground maximum Z coordinate
  29134. * @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
  29135. * @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
  29136. * @param scene defines the hosting scene
  29137. * @param updatable defines if the mesh must be flagged as updatable
  29138. * @returns a new Mesh
  29139. */
  29140. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29141. w: number;
  29142. h: number;
  29143. }, precision: {
  29144. w: number;
  29145. h: number;
  29146. }, scene: Scene, updatable?: boolean): Mesh;
  29147. /**
  29148. * Creates a ground mesh from a height map.
  29149. * Please consider using the same method from the MeshBuilder class instead
  29150. * @see https://doc.babylonjs.com/babylon101/height_map
  29151. * @param name defines the name of the mesh to create
  29152. * @param url sets the URL of the height map image resource
  29153. * @param width set the ground width size
  29154. * @param height set the ground height size
  29155. * @param subdivisions sets the number of subdivision per side
  29156. * @param minHeight is the minimum altitude on the ground
  29157. * @param maxHeight is the maximum altitude on the ground
  29158. * @param scene defines the hosting scene
  29159. * @param updatable defines if the mesh must be flagged as updatable
  29160. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29161. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29162. * @returns a new Mesh
  29163. */
  29164. 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;
  29165. /**
  29166. * Creates a tube mesh.
  29167. * The tube is a parametric shape.
  29168. * It has no predefined shape. Its final shape will depend on the input parameters.
  29169. * Please consider using the same method from the MeshBuilder class instead
  29170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29171. * @param name defines the name of the mesh to create
  29172. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29173. * @param radius sets the tube radius size
  29174. * @param tessellation is the number of sides on the tubular surface
  29175. * @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
  29176. * @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
  29177. * @param scene defines the hosting scene
  29178. * @param updatable defines if the mesh must be flagged as updatable
  29179. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29180. * @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)
  29181. * @returns a new Mesh
  29182. */
  29183. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29184. (i: number, distance: number): number;
  29185. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29186. /**
  29187. * Creates a polyhedron mesh.
  29188. * Please consider using the same method from the MeshBuilder class instead.
  29189. * * 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
  29190. * * The parameter `size` (positive float, default 1) sets the polygon size
  29191. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29192. * * 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`
  29193. * * 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
  29194. * * 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)`)
  29195. * * 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
  29196. * * 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
  29197. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29198. * * 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
  29199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29200. * @param name defines the name of the mesh to create
  29201. * @param options defines the options used to create the mesh
  29202. * @param scene defines the hosting scene
  29203. * @returns a new Mesh
  29204. */
  29205. static CreatePolyhedron(name: string, options: {
  29206. type?: number;
  29207. size?: number;
  29208. sizeX?: number;
  29209. sizeY?: number;
  29210. sizeZ?: number;
  29211. custom?: any;
  29212. faceUV?: Vector4[];
  29213. faceColors?: Color4[];
  29214. updatable?: boolean;
  29215. sideOrientation?: number;
  29216. }, scene: Scene): Mesh;
  29217. /**
  29218. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29219. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29220. * * 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`)
  29221. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29222. * * 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
  29223. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29224. * * 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
  29225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29226. * @param name defines the name of the mesh
  29227. * @param options defines the options used to create the mesh
  29228. * @param scene defines the hosting scene
  29229. * @returns a new Mesh
  29230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29231. */
  29232. static CreateIcoSphere(name: string, options: {
  29233. radius?: number;
  29234. flat?: boolean;
  29235. subdivisions?: number;
  29236. sideOrientation?: number;
  29237. updatable?: boolean;
  29238. }, scene: Scene): Mesh;
  29239. /**
  29240. * Creates a decal mesh.
  29241. * Please consider using the same method from the MeshBuilder class instead.
  29242. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29243. * @param name defines the name of the mesh
  29244. * @param sourceMesh defines the mesh receiving the decal
  29245. * @param position sets the position of the decal in world coordinates
  29246. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29247. * @param size sets the decal scaling
  29248. * @param angle sets the angle to rotate the decal
  29249. * @returns a new Mesh
  29250. */
  29251. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29252. /**
  29253. * Prepare internal position array for software CPU skinning
  29254. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29255. */
  29256. setPositionsForCPUSkinning(): Float32Array;
  29257. /**
  29258. * Prepare internal normal array for software CPU skinning
  29259. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29260. */
  29261. setNormalsForCPUSkinning(): Float32Array;
  29262. /**
  29263. * Updates the vertex buffer by applying transformation from the bones
  29264. * @param skeleton defines the skeleton to apply to current mesh
  29265. * @returns the current mesh
  29266. */
  29267. applySkeleton(skeleton: Skeleton): Mesh;
  29268. /**
  29269. * 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
  29270. * @param meshes defines the list of meshes to scan
  29271. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29272. */
  29273. static MinMax(meshes: AbstractMesh[]): {
  29274. min: Vector3;
  29275. max: Vector3;
  29276. };
  29277. /**
  29278. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29279. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29280. * @returns a vector3
  29281. */
  29282. static Center(meshesOrMinMaxVector: {
  29283. min: Vector3;
  29284. max: Vector3;
  29285. } | AbstractMesh[]): Vector3;
  29286. /**
  29287. * Merge the array of meshes into a single mesh for performance reasons.
  29288. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29289. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29290. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29291. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29292. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29293. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29294. * @returns a new mesh
  29295. */
  29296. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29297. /** @hidden */
  29298. addInstance(instance: InstancedMesh): void;
  29299. /** @hidden */
  29300. removeInstance(instance: InstancedMesh): void;
  29301. }
  29302. }
  29303. declare module BABYLON {
  29304. /**
  29305. * This is the base class of all the camera used in the application.
  29306. * @see https://doc.babylonjs.com/features/cameras
  29307. */
  29308. export class Camera extends Node {
  29309. /** @hidden */
  29310. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29311. /**
  29312. * This is the default projection mode used by the cameras.
  29313. * It helps recreating a feeling of perspective and better appreciate depth.
  29314. * This is the best way to simulate real life cameras.
  29315. */
  29316. static readonly PERSPECTIVE_CAMERA: number;
  29317. /**
  29318. * This helps creating camera with an orthographic mode.
  29319. * 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.
  29320. */
  29321. static readonly ORTHOGRAPHIC_CAMERA: number;
  29322. /**
  29323. * This is the default FOV mode for perspective cameras.
  29324. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29325. */
  29326. static readonly FOVMODE_VERTICAL_FIXED: number;
  29327. /**
  29328. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29329. */
  29330. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29331. /**
  29332. * This specifies ther is no need for a camera rig.
  29333. * Basically only one eye is rendered corresponding to the camera.
  29334. */
  29335. static readonly RIG_MODE_NONE: number;
  29336. /**
  29337. * Simulates a camera Rig with one blue eye and one red eye.
  29338. * This can be use with 3d blue and red glasses.
  29339. */
  29340. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29341. /**
  29342. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29343. */
  29344. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29345. /**
  29346. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29347. */
  29348. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29349. /**
  29350. * Defines that both eyes of the camera will be rendered over under each other.
  29351. */
  29352. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29353. /**
  29354. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29355. */
  29356. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29357. /**
  29358. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29359. */
  29360. static readonly RIG_MODE_VR: number;
  29361. /**
  29362. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29363. */
  29364. static readonly RIG_MODE_WEBVR: number;
  29365. /**
  29366. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29367. */
  29368. static readonly RIG_MODE_CUSTOM: number;
  29369. /**
  29370. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29371. */
  29372. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29373. /**
  29374. * Define the input manager associated with the camera.
  29375. */
  29376. inputs: CameraInputsManager<Camera>;
  29377. /** @hidden */
  29378. _position: Vector3;
  29379. /**
  29380. * Define the current local position of the camera in the scene
  29381. */
  29382. get position(): Vector3;
  29383. set position(newPosition: Vector3);
  29384. protected _upVector: Vector3;
  29385. /**
  29386. * The vector the camera should consider as up.
  29387. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29388. */
  29389. set upVector(vec: Vector3);
  29390. get upVector(): Vector3;
  29391. /**
  29392. * Define the current limit on the left side for an orthographic camera
  29393. * In scene unit
  29394. */
  29395. orthoLeft: Nullable<number>;
  29396. /**
  29397. * Define the current limit on the right side for an orthographic camera
  29398. * In scene unit
  29399. */
  29400. orthoRight: Nullable<number>;
  29401. /**
  29402. * Define the current limit on the bottom side for an orthographic camera
  29403. * In scene unit
  29404. */
  29405. orthoBottom: Nullable<number>;
  29406. /**
  29407. * Define the current limit on the top side for an orthographic camera
  29408. * In scene unit
  29409. */
  29410. orthoTop: Nullable<number>;
  29411. /**
  29412. * Field Of View is set in Radians. (default is 0.8)
  29413. */
  29414. fov: number;
  29415. /**
  29416. * Define the minimum distance the camera can see from.
  29417. * This is important to note that the depth buffer are not infinite and the closer it starts
  29418. * the more your scene might encounter depth fighting issue.
  29419. */
  29420. minZ: number;
  29421. /**
  29422. * Define the maximum distance the camera can see to.
  29423. * This is important to note that the depth buffer are not infinite and the further it end
  29424. * the more your scene might encounter depth fighting issue.
  29425. */
  29426. maxZ: number;
  29427. /**
  29428. * Define the default inertia of the camera.
  29429. * This helps giving a smooth feeling to the camera movement.
  29430. */
  29431. inertia: number;
  29432. /**
  29433. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29434. */
  29435. mode: number;
  29436. /**
  29437. * Define whether the camera is intermediate.
  29438. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29439. */
  29440. isIntermediate: boolean;
  29441. /**
  29442. * Define the viewport of the camera.
  29443. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29444. */
  29445. viewport: Viewport;
  29446. /**
  29447. * Restricts the camera to viewing objects with the same layerMask.
  29448. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29449. */
  29450. layerMask: number;
  29451. /**
  29452. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29453. */
  29454. fovMode: number;
  29455. /**
  29456. * Rig mode of the camera.
  29457. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29458. * This is normally controlled byt the camera themselves as internal use.
  29459. */
  29460. cameraRigMode: number;
  29461. /**
  29462. * Defines the distance between both "eyes" in case of a RIG
  29463. */
  29464. interaxialDistance: number;
  29465. /**
  29466. * Defines if stereoscopic rendering is done side by side or over under.
  29467. */
  29468. isStereoscopicSideBySide: boolean;
  29469. /**
  29470. * 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
  29471. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29472. * else in the scene. (Eg. security camera)
  29473. *
  29474. * 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)
  29475. */
  29476. customRenderTargets: RenderTargetTexture[];
  29477. /**
  29478. * When set, the camera will render to this render target instead of the default canvas
  29479. *
  29480. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29481. */
  29482. outputRenderTarget: Nullable<RenderTargetTexture>;
  29483. /**
  29484. * Observable triggered when the camera view matrix has changed.
  29485. */
  29486. onViewMatrixChangedObservable: Observable<Camera>;
  29487. /**
  29488. * Observable triggered when the camera Projection matrix has changed.
  29489. */
  29490. onProjectionMatrixChangedObservable: Observable<Camera>;
  29491. /**
  29492. * Observable triggered when the inputs have been processed.
  29493. */
  29494. onAfterCheckInputsObservable: Observable<Camera>;
  29495. /**
  29496. * Observable triggered when reset has been called and applied to the camera.
  29497. */
  29498. onRestoreStateObservable: Observable<Camera>;
  29499. /**
  29500. * Is this camera a part of a rig system?
  29501. */
  29502. isRigCamera: boolean;
  29503. /**
  29504. * If isRigCamera set to true this will be set with the parent camera.
  29505. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29506. */
  29507. rigParent?: Camera;
  29508. /** @hidden */
  29509. _cameraRigParams: any;
  29510. /** @hidden */
  29511. _rigCameras: Camera[];
  29512. /** @hidden */
  29513. _rigPostProcess: Nullable<PostProcess>;
  29514. protected _webvrViewMatrix: Matrix;
  29515. /** @hidden */
  29516. _skipRendering: boolean;
  29517. /** @hidden */
  29518. _projectionMatrix: Matrix;
  29519. /** @hidden */
  29520. _postProcesses: Nullable<PostProcess>[];
  29521. /** @hidden */
  29522. _activeMeshes: SmartArray<AbstractMesh>;
  29523. protected _globalPosition: Vector3;
  29524. /** @hidden */
  29525. _computedViewMatrix: Matrix;
  29526. private _doNotComputeProjectionMatrix;
  29527. private _transformMatrix;
  29528. private _frustumPlanes;
  29529. private _refreshFrustumPlanes;
  29530. private _storedFov;
  29531. private _stateStored;
  29532. /**
  29533. * Instantiates a new camera object.
  29534. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29535. * @see https://doc.babylonjs.com/features/cameras
  29536. * @param name Defines the name of the camera in the scene
  29537. * @param position Defines the position of the camera
  29538. * @param scene Defines the scene the camera belongs too
  29539. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29540. */
  29541. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29542. /**
  29543. * Store current camera state (fov, position, etc..)
  29544. * @returns the camera
  29545. */
  29546. storeState(): Camera;
  29547. /**
  29548. * Restores the camera state values if it has been stored. You must call storeState() first
  29549. */
  29550. protected _restoreStateValues(): boolean;
  29551. /**
  29552. * Restored camera state. You must call storeState() first.
  29553. * @returns true if restored and false otherwise
  29554. */
  29555. restoreState(): boolean;
  29556. /**
  29557. * Gets the class name of the camera.
  29558. * @returns the class name
  29559. */
  29560. getClassName(): string;
  29561. /** @hidden */
  29562. readonly _isCamera: boolean;
  29563. /**
  29564. * Gets a string representation of the camera useful for debug purpose.
  29565. * @param fullDetails Defines that a more verboe level of logging is required
  29566. * @returns the string representation
  29567. */
  29568. toString(fullDetails?: boolean): string;
  29569. /**
  29570. * Gets the current world space position of the camera.
  29571. */
  29572. get globalPosition(): Vector3;
  29573. /**
  29574. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29575. * @returns the active meshe list
  29576. */
  29577. getActiveMeshes(): SmartArray<AbstractMesh>;
  29578. /**
  29579. * Check whether a mesh is part of the current active mesh list of the camera
  29580. * @param mesh Defines the mesh to check
  29581. * @returns true if active, false otherwise
  29582. */
  29583. isActiveMesh(mesh: Mesh): boolean;
  29584. /**
  29585. * Is this camera ready to be used/rendered
  29586. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29587. * @return true if the camera is ready
  29588. */
  29589. isReady(completeCheck?: boolean): boolean;
  29590. /** @hidden */
  29591. _initCache(): void;
  29592. /** @hidden */
  29593. _updateCache(ignoreParentClass?: boolean): void;
  29594. /** @hidden */
  29595. _isSynchronized(): boolean;
  29596. /** @hidden */
  29597. _isSynchronizedViewMatrix(): boolean;
  29598. /** @hidden */
  29599. _isSynchronizedProjectionMatrix(): boolean;
  29600. /**
  29601. * Attach the input controls to a specific dom element to get the input from.
  29602. * @param element Defines the element the controls should be listened from
  29603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29604. */
  29605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29606. /**
  29607. * Detach the current controls from the specified dom element.
  29608. * @param element Defines the element to stop listening the inputs from
  29609. */
  29610. detachControl(element: HTMLElement): void;
  29611. /**
  29612. * Update the camera state according to the different inputs gathered during the frame.
  29613. */
  29614. update(): void;
  29615. /** @hidden */
  29616. _checkInputs(): void;
  29617. /** @hidden */
  29618. get rigCameras(): Camera[];
  29619. /**
  29620. * Gets the post process used by the rig cameras
  29621. */
  29622. get rigPostProcess(): Nullable<PostProcess>;
  29623. /**
  29624. * Internal, gets the first post proces.
  29625. * @returns the first post process to be run on this camera.
  29626. */
  29627. _getFirstPostProcess(): Nullable<PostProcess>;
  29628. private _cascadePostProcessesToRigCams;
  29629. /**
  29630. * Attach a post process to the camera.
  29631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29632. * @param postProcess The post process to attach to the camera
  29633. * @param insertAt The position of the post process in case several of them are in use in the scene
  29634. * @returns the position the post process has been inserted at
  29635. */
  29636. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29637. /**
  29638. * Detach a post process to the camera.
  29639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29640. * @param postProcess The post process to detach from the camera
  29641. */
  29642. detachPostProcess(postProcess: PostProcess): void;
  29643. /**
  29644. * Gets the current world matrix of the camera
  29645. */
  29646. getWorldMatrix(): Matrix;
  29647. /** @hidden */
  29648. _getViewMatrix(): Matrix;
  29649. /**
  29650. * Gets the current view matrix of the camera.
  29651. * @param force forces the camera to recompute the matrix without looking at the cached state
  29652. * @returns the view matrix
  29653. */
  29654. getViewMatrix(force?: boolean): Matrix;
  29655. /**
  29656. * Freeze the projection matrix.
  29657. * It will prevent the cache check of the camera projection compute and can speed up perf
  29658. * if no parameter of the camera are meant to change
  29659. * @param projection Defines manually a projection if necessary
  29660. */
  29661. freezeProjectionMatrix(projection?: Matrix): void;
  29662. /**
  29663. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29664. */
  29665. unfreezeProjectionMatrix(): void;
  29666. /**
  29667. * Gets the current projection matrix of the camera.
  29668. * @param force forces the camera to recompute the matrix without looking at the cached state
  29669. * @returns the projection matrix
  29670. */
  29671. getProjectionMatrix(force?: boolean): Matrix;
  29672. /**
  29673. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29674. * @returns a Matrix
  29675. */
  29676. getTransformationMatrix(): Matrix;
  29677. private _updateFrustumPlanes;
  29678. /**
  29679. * Checks if a cullable object (mesh...) is in the camera frustum
  29680. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29681. * @param target The object to check
  29682. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29683. * @returns true if the object is in frustum otherwise false
  29684. */
  29685. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29686. /**
  29687. * Checks if a cullable object (mesh...) is in the camera frustum
  29688. * Unlike isInFrustum this cheks the full bounding box
  29689. * @param target The object to check
  29690. * @returns true if the object is in frustum otherwise false
  29691. */
  29692. isCompletelyInFrustum(target: ICullable): boolean;
  29693. /**
  29694. * Gets a ray in the forward direction from the camera.
  29695. * @param length Defines the length of the ray to create
  29696. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29697. * @param origin Defines the start point of the ray which defaults to the camera position
  29698. * @returns the forward ray
  29699. */
  29700. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29701. /**
  29702. * Gets a ray in the forward direction from the camera.
  29703. * @param refRay the ray to (re)use when setting the values
  29704. * @param length Defines the length of the ray to create
  29705. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29706. * @param origin Defines the start point of the ray which defaults to the camera position
  29707. * @returns the forward ray
  29708. */
  29709. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29710. /**
  29711. * Releases resources associated with this node.
  29712. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29713. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29714. */
  29715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29716. /** @hidden */
  29717. _isLeftCamera: boolean;
  29718. /**
  29719. * Gets the left camera of a rig setup in case of Rigged Camera
  29720. */
  29721. get isLeftCamera(): boolean;
  29722. /** @hidden */
  29723. _isRightCamera: boolean;
  29724. /**
  29725. * Gets the right camera of a rig setup in case of Rigged Camera
  29726. */
  29727. get isRightCamera(): boolean;
  29728. /**
  29729. * Gets the left camera of a rig setup in case of Rigged Camera
  29730. */
  29731. get leftCamera(): Nullable<FreeCamera>;
  29732. /**
  29733. * Gets the right camera of a rig setup in case of Rigged Camera
  29734. */
  29735. get rightCamera(): Nullable<FreeCamera>;
  29736. /**
  29737. * Gets the left camera target of a rig setup in case of Rigged Camera
  29738. * @returns the target position
  29739. */
  29740. getLeftTarget(): Nullable<Vector3>;
  29741. /**
  29742. * Gets the right camera target of a rig setup in case of Rigged Camera
  29743. * @returns the target position
  29744. */
  29745. getRightTarget(): Nullable<Vector3>;
  29746. /**
  29747. * @hidden
  29748. */
  29749. setCameraRigMode(mode: number, rigParams: any): void;
  29750. /** @hidden */
  29751. static _setStereoscopicRigMode(camera: Camera): void;
  29752. /** @hidden */
  29753. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29754. /** @hidden */
  29755. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29756. /** @hidden */
  29757. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29758. /** @hidden */
  29759. _getVRProjectionMatrix(): Matrix;
  29760. protected _updateCameraRotationMatrix(): void;
  29761. protected _updateWebVRCameraRotationMatrix(): void;
  29762. /**
  29763. * This function MUST be overwritten by the different WebVR cameras available.
  29764. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29765. * @hidden
  29766. */
  29767. _getWebVRProjectionMatrix(): Matrix;
  29768. /**
  29769. * This function MUST be overwritten by the different WebVR cameras available.
  29770. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29771. * @hidden
  29772. */
  29773. _getWebVRViewMatrix(): Matrix;
  29774. /** @hidden */
  29775. setCameraRigParameter(name: string, value: any): void;
  29776. /**
  29777. * needs to be overridden by children so sub has required properties to be copied
  29778. * @hidden
  29779. */
  29780. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29781. /**
  29782. * May need to be overridden by children
  29783. * @hidden
  29784. */
  29785. _updateRigCameras(): void;
  29786. /** @hidden */
  29787. _setupInputs(): void;
  29788. /**
  29789. * Serialiaze the camera setup to a json represention
  29790. * @returns the JSON representation
  29791. */
  29792. serialize(): any;
  29793. /**
  29794. * Clones the current camera.
  29795. * @param name The cloned camera name
  29796. * @returns the cloned camera
  29797. */
  29798. clone(name: string): Camera;
  29799. /**
  29800. * Gets the direction of the camera relative to a given local axis.
  29801. * @param localAxis Defines the reference axis to provide a relative direction.
  29802. * @return the direction
  29803. */
  29804. getDirection(localAxis: Vector3): Vector3;
  29805. /**
  29806. * Returns the current camera absolute rotation
  29807. */
  29808. get absoluteRotation(): Quaternion;
  29809. /**
  29810. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29811. * @param localAxis Defines the reference axis to provide a relative direction.
  29812. * @param result Defines the vector to store the result in
  29813. */
  29814. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29815. /**
  29816. * Gets a camera constructor for a given camera type
  29817. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29818. * @param name The name of the camera the result will be able to instantiate
  29819. * @param scene The scene the result will construct the camera in
  29820. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29821. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29822. * @returns a factory method to construc the camera
  29823. */
  29824. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29825. /**
  29826. * Compute the world matrix of the camera.
  29827. * @returns the camera world matrix
  29828. */
  29829. computeWorldMatrix(): Matrix;
  29830. /**
  29831. * Parse a JSON and creates the camera from the parsed information
  29832. * @param parsedCamera The JSON to parse
  29833. * @param scene The scene to instantiate the camera in
  29834. * @returns the newly constructed camera
  29835. */
  29836. static Parse(parsedCamera: any, scene: Scene): Camera;
  29837. }
  29838. }
  29839. declare module BABYLON {
  29840. /**
  29841. * Class containing static functions to help procedurally build meshes
  29842. */
  29843. export class DiscBuilder {
  29844. /**
  29845. * Creates a plane polygonal mesh. By default, this is a disc
  29846. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29847. * * 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
  29848. * * 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
  29849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29850. * * 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
  29851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29852. * @param name defines the name of the mesh
  29853. * @param options defines the options used to create the mesh
  29854. * @param scene defines the hosting scene
  29855. * @returns the plane polygonal mesh
  29856. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29857. */
  29858. static CreateDisc(name: string, options: {
  29859. radius?: number;
  29860. tessellation?: number;
  29861. arc?: number;
  29862. updatable?: boolean;
  29863. sideOrientation?: number;
  29864. frontUVs?: Vector4;
  29865. backUVs?: Vector4;
  29866. }, scene?: Nullable<Scene>): Mesh;
  29867. }
  29868. }
  29869. declare module BABYLON {
  29870. /**
  29871. * Options to be used when creating a FresnelParameters.
  29872. */
  29873. export type IFresnelParametersCreationOptions = {
  29874. /**
  29875. * Define the color used on edges (grazing angle)
  29876. */
  29877. leftColor?: Color3;
  29878. /**
  29879. * Define the color used on center
  29880. */
  29881. rightColor?: Color3;
  29882. /**
  29883. * Define bias applied to computed fresnel term
  29884. */
  29885. bias?: number;
  29886. /**
  29887. * Defined the power exponent applied to fresnel term
  29888. */
  29889. power?: number;
  29890. /**
  29891. * Define if the fresnel effect is enable or not.
  29892. */
  29893. isEnabled?: boolean;
  29894. };
  29895. /**
  29896. * Serialized format for FresnelParameters.
  29897. */
  29898. export type IFresnelParametersSerialized = {
  29899. /**
  29900. * Define the color used on edges (grazing angle) [as an array]
  29901. */
  29902. leftColor: number[];
  29903. /**
  29904. * Define the color used on center [as an array]
  29905. */
  29906. rightColor: number[];
  29907. /**
  29908. * Define bias applied to computed fresnel term
  29909. */
  29910. bias: number;
  29911. /**
  29912. * Defined the power exponent applied to fresnel term
  29913. */
  29914. power?: number;
  29915. /**
  29916. * Define if the fresnel effect is enable or not.
  29917. */
  29918. isEnabled: boolean;
  29919. };
  29920. /**
  29921. * This represents all the required information to add a fresnel effect on a material:
  29922. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29923. */
  29924. export class FresnelParameters {
  29925. private _isEnabled;
  29926. /**
  29927. * Define if the fresnel effect is enable or not.
  29928. */
  29929. get isEnabled(): boolean;
  29930. set isEnabled(value: boolean);
  29931. /**
  29932. * Define the color used on edges (grazing angle)
  29933. */
  29934. leftColor: Color3;
  29935. /**
  29936. * Define the color used on center
  29937. */
  29938. rightColor: Color3;
  29939. /**
  29940. * Define bias applied to computed fresnel term
  29941. */
  29942. bias: number;
  29943. /**
  29944. * Defined the power exponent applied to fresnel term
  29945. */
  29946. power: number;
  29947. /**
  29948. * Creates a new FresnelParameters object.
  29949. *
  29950. * @param options provide your own settings to optionally to override defaults
  29951. */
  29952. constructor(options?: IFresnelParametersCreationOptions);
  29953. /**
  29954. * Clones the current fresnel and its valuues
  29955. * @returns a clone fresnel configuration
  29956. */
  29957. clone(): FresnelParameters;
  29958. /**
  29959. * Determines equality between FresnelParameters objects
  29960. * @param otherFresnelParameters defines the second operand
  29961. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29962. */
  29963. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29964. /**
  29965. * Serializes the current fresnel parameters to a JSON representation.
  29966. * @return the JSON serialization
  29967. */
  29968. serialize(): IFresnelParametersSerialized;
  29969. /**
  29970. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29971. * @param parsedFresnelParameters Define the JSON representation
  29972. * @returns the parsed parameters
  29973. */
  29974. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29975. }
  29976. }
  29977. declare module BABYLON {
  29978. /**
  29979. * This groups all the flags used to control the materials channel.
  29980. */
  29981. export class MaterialFlags {
  29982. private static _DiffuseTextureEnabled;
  29983. /**
  29984. * Are diffuse textures enabled in the application.
  29985. */
  29986. static get DiffuseTextureEnabled(): boolean;
  29987. static set DiffuseTextureEnabled(value: boolean);
  29988. private static _DetailTextureEnabled;
  29989. /**
  29990. * Are detail textures enabled in the application.
  29991. */
  29992. static get DetailTextureEnabled(): boolean;
  29993. static set DetailTextureEnabled(value: boolean);
  29994. private static _AmbientTextureEnabled;
  29995. /**
  29996. * Are ambient textures enabled in the application.
  29997. */
  29998. static get AmbientTextureEnabled(): boolean;
  29999. static set AmbientTextureEnabled(value: boolean);
  30000. private static _OpacityTextureEnabled;
  30001. /**
  30002. * Are opacity textures enabled in the application.
  30003. */
  30004. static get OpacityTextureEnabled(): boolean;
  30005. static set OpacityTextureEnabled(value: boolean);
  30006. private static _ReflectionTextureEnabled;
  30007. /**
  30008. * Are reflection textures enabled in the application.
  30009. */
  30010. static get ReflectionTextureEnabled(): boolean;
  30011. static set ReflectionTextureEnabled(value: boolean);
  30012. private static _EmissiveTextureEnabled;
  30013. /**
  30014. * Are emissive textures enabled in the application.
  30015. */
  30016. static get EmissiveTextureEnabled(): boolean;
  30017. static set EmissiveTextureEnabled(value: boolean);
  30018. private static _SpecularTextureEnabled;
  30019. /**
  30020. * Are specular textures enabled in the application.
  30021. */
  30022. static get SpecularTextureEnabled(): boolean;
  30023. static set SpecularTextureEnabled(value: boolean);
  30024. private static _BumpTextureEnabled;
  30025. /**
  30026. * Are bump textures enabled in the application.
  30027. */
  30028. static get BumpTextureEnabled(): boolean;
  30029. static set BumpTextureEnabled(value: boolean);
  30030. private static _LightmapTextureEnabled;
  30031. /**
  30032. * Are lightmap textures enabled in the application.
  30033. */
  30034. static get LightmapTextureEnabled(): boolean;
  30035. static set LightmapTextureEnabled(value: boolean);
  30036. private static _RefractionTextureEnabled;
  30037. /**
  30038. * Are refraction textures enabled in the application.
  30039. */
  30040. static get RefractionTextureEnabled(): boolean;
  30041. static set RefractionTextureEnabled(value: boolean);
  30042. private static _ColorGradingTextureEnabled;
  30043. /**
  30044. * Are color grading textures enabled in the application.
  30045. */
  30046. static get ColorGradingTextureEnabled(): boolean;
  30047. static set ColorGradingTextureEnabled(value: boolean);
  30048. private static _FresnelEnabled;
  30049. /**
  30050. * Are fresnels enabled in the application.
  30051. */
  30052. static get FresnelEnabled(): boolean;
  30053. static set FresnelEnabled(value: boolean);
  30054. private static _ClearCoatTextureEnabled;
  30055. /**
  30056. * Are clear coat textures enabled in the application.
  30057. */
  30058. static get ClearCoatTextureEnabled(): boolean;
  30059. static set ClearCoatTextureEnabled(value: boolean);
  30060. private static _ClearCoatBumpTextureEnabled;
  30061. /**
  30062. * Are clear coat bump textures enabled in the application.
  30063. */
  30064. static get ClearCoatBumpTextureEnabled(): boolean;
  30065. static set ClearCoatBumpTextureEnabled(value: boolean);
  30066. private static _ClearCoatTintTextureEnabled;
  30067. /**
  30068. * Are clear coat tint textures enabled in the application.
  30069. */
  30070. static get ClearCoatTintTextureEnabled(): boolean;
  30071. static set ClearCoatTintTextureEnabled(value: boolean);
  30072. private static _SheenTextureEnabled;
  30073. /**
  30074. * Are sheen textures enabled in the application.
  30075. */
  30076. static get SheenTextureEnabled(): boolean;
  30077. static set SheenTextureEnabled(value: boolean);
  30078. private static _AnisotropicTextureEnabled;
  30079. /**
  30080. * Are anisotropic textures enabled in the application.
  30081. */
  30082. static get AnisotropicTextureEnabled(): boolean;
  30083. static set AnisotropicTextureEnabled(value: boolean);
  30084. private static _ThicknessTextureEnabled;
  30085. /**
  30086. * Are thickness textures enabled in the application.
  30087. */
  30088. static get ThicknessTextureEnabled(): boolean;
  30089. static set ThicknessTextureEnabled(value: boolean);
  30090. }
  30091. }
  30092. declare module BABYLON {
  30093. /** @hidden */
  30094. export var defaultFragmentDeclaration: {
  30095. name: string;
  30096. shader: string;
  30097. };
  30098. }
  30099. declare module BABYLON {
  30100. /** @hidden */
  30101. export var defaultUboDeclaration: {
  30102. name: string;
  30103. shader: string;
  30104. };
  30105. }
  30106. declare module BABYLON {
  30107. /** @hidden */
  30108. export var prePassDeclaration: {
  30109. name: string;
  30110. shader: string;
  30111. };
  30112. }
  30113. declare module BABYLON {
  30114. /** @hidden */
  30115. export var lightFragmentDeclaration: {
  30116. name: string;
  30117. shader: string;
  30118. };
  30119. }
  30120. declare module BABYLON {
  30121. /** @hidden */
  30122. export var lightUboDeclaration: {
  30123. name: string;
  30124. shader: string;
  30125. };
  30126. }
  30127. declare module BABYLON {
  30128. /** @hidden */
  30129. export var lightsFragmentFunctions: {
  30130. name: string;
  30131. shader: string;
  30132. };
  30133. }
  30134. declare module BABYLON {
  30135. /** @hidden */
  30136. export var shadowsFragmentFunctions: {
  30137. name: string;
  30138. shader: string;
  30139. };
  30140. }
  30141. declare module BABYLON {
  30142. /** @hidden */
  30143. export var fresnelFunction: {
  30144. name: string;
  30145. shader: string;
  30146. };
  30147. }
  30148. declare module BABYLON {
  30149. /** @hidden */
  30150. export var bumpFragmentMainFunctions: {
  30151. name: string;
  30152. shader: string;
  30153. };
  30154. }
  30155. declare module BABYLON {
  30156. /** @hidden */
  30157. export var bumpFragmentFunctions: {
  30158. name: string;
  30159. shader: string;
  30160. };
  30161. }
  30162. declare module BABYLON {
  30163. /** @hidden */
  30164. export var logDepthDeclaration: {
  30165. name: string;
  30166. shader: string;
  30167. };
  30168. }
  30169. declare module BABYLON {
  30170. /** @hidden */
  30171. export var bumpFragment: {
  30172. name: string;
  30173. shader: string;
  30174. };
  30175. }
  30176. declare module BABYLON {
  30177. /** @hidden */
  30178. export var depthPrePass: {
  30179. name: string;
  30180. shader: string;
  30181. };
  30182. }
  30183. declare module BABYLON {
  30184. /** @hidden */
  30185. export var lightFragment: {
  30186. name: string;
  30187. shader: string;
  30188. };
  30189. }
  30190. declare module BABYLON {
  30191. /** @hidden */
  30192. export var logDepthFragment: {
  30193. name: string;
  30194. shader: string;
  30195. };
  30196. }
  30197. declare module BABYLON {
  30198. /** @hidden */
  30199. export var defaultPixelShader: {
  30200. name: string;
  30201. shader: string;
  30202. };
  30203. }
  30204. declare module BABYLON {
  30205. /** @hidden */
  30206. export var defaultVertexDeclaration: {
  30207. name: string;
  30208. shader: string;
  30209. };
  30210. }
  30211. declare module BABYLON {
  30212. /** @hidden */
  30213. export var bumpVertexDeclaration: {
  30214. name: string;
  30215. shader: string;
  30216. };
  30217. }
  30218. declare module BABYLON {
  30219. /** @hidden */
  30220. export var bumpVertex: {
  30221. name: string;
  30222. shader: string;
  30223. };
  30224. }
  30225. declare module BABYLON {
  30226. /** @hidden */
  30227. export var fogVertex: {
  30228. name: string;
  30229. shader: string;
  30230. };
  30231. }
  30232. declare module BABYLON {
  30233. /** @hidden */
  30234. export var shadowsVertex: {
  30235. name: string;
  30236. shader: string;
  30237. };
  30238. }
  30239. declare module BABYLON {
  30240. /** @hidden */
  30241. export var pointCloudVertex: {
  30242. name: string;
  30243. shader: string;
  30244. };
  30245. }
  30246. declare module BABYLON {
  30247. /** @hidden */
  30248. export var logDepthVertex: {
  30249. name: string;
  30250. shader: string;
  30251. };
  30252. }
  30253. declare module BABYLON {
  30254. /** @hidden */
  30255. export var defaultVertexShader: {
  30256. name: string;
  30257. shader: string;
  30258. };
  30259. }
  30260. declare module BABYLON {
  30261. /**
  30262. * @hidden
  30263. */
  30264. export interface IMaterialDetailMapDefines {
  30265. DETAIL: boolean;
  30266. DETAILDIRECTUV: number;
  30267. DETAIL_NORMALBLENDMETHOD: number;
  30268. /** @hidden */
  30269. _areTexturesDirty: boolean;
  30270. }
  30271. /**
  30272. * Define the code related to the detail map parameters of a material
  30273. *
  30274. * Inspired from:
  30275. * 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
  30276. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30277. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30278. */
  30279. export class DetailMapConfiguration {
  30280. private _texture;
  30281. /**
  30282. * The detail texture of the material.
  30283. */
  30284. texture: Nullable<BaseTexture>;
  30285. /**
  30286. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30287. * Bigger values mean stronger blending
  30288. */
  30289. diffuseBlendLevel: number;
  30290. /**
  30291. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30292. * Bigger values mean stronger blending. Only used with PBR materials
  30293. */
  30294. roughnessBlendLevel: number;
  30295. /**
  30296. * Defines how strong the bump effect from the detail map is
  30297. * Bigger values mean stronger effect
  30298. */
  30299. bumpLevel: number;
  30300. private _normalBlendMethod;
  30301. /**
  30302. * The method used to blend the bump and detail normals together
  30303. */
  30304. normalBlendMethod: number;
  30305. private _isEnabled;
  30306. /**
  30307. * Enable or disable the detail map on this material
  30308. */
  30309. isEnabled: boolean;
  30310. /** @hidden */
  30311. private _internalMarkAllSubMeshesAsTexturesDirty;
  30312. /** @hidden */
  30313. _markAllSubMeshesAsTexturesDirty(): void;
  30314. /**
  30315. * Instantiate a new detail map
  30316. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30317. */
  30318. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30319. /**
  30320. * Gets whether the submesh is ready to be used or not.
  30321. * @param defines the list of "defines" to update.
  30322. * @param scene defines the scene the material belongs to.
  30323. * @returns - boolean indicating that the submesh is ready or not.
  30324. */
  30325. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30326. /**
  30327. * Update the defines for detail map usage
  30328. * @param defines the list of "defines" to update.
  30329. * @param scene defines the scene the material belongs to.
  30330. */
  30331. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30332. /**
  30333. * Binds the material data.
  30334. * @param uniformBuffer defines the Uniform buffer to fill in.
  30335. * @param scene defines the scene the material belongs to.
  30336. * @param isFrozen defines whether the material is frozen or not.
  30337. */
  30338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30339. /**
  30340. * Checks to see if a texture is used in the material.
  30341. * @param texture - Base texture to use.
  30342. * @returns - Boolean specifying if a texture is used in the material.
  30343. */
  30344. hasTexture(texture: BaseTexture): boolean;
  30345. /**
  30346. * Returns an array of the actively used textures.
  30347. * @param activeTextures Array of BaseTextures
  30348. */
  30349. getActiveTextures(activeTextures: BaseTexture[]): void;
  30350. /**
  30351. * Returns the animatable textures.
  30352. * @param animatables Array of animatable textures.
  30353. */
  30354. getAnimatables(animatables: IAnimatable[]): void;
  30355. /**
  30356. * Disposes the resources of the material.
  30357. * @param forceDisposeTextures - Forces the disposal of all textures.
  30358. */
  30359. dispose(forceDisposeTextures?: boolean): void;
  30360. /**
  30361. * Get the current class name useful for serialization or dynamic coding.
  30362. * @returns "DetailMap"
  30363. */
  30364. getClassName(): string;
  30365. /**
  30366. * Add the required uniforms to the current list.
  30367. * @param uniforms defines the current uniform list.
  30368. */
  30369. static AddUniforms(uniforms: string[]): void;
  30370. /**
  30371. * Add the required samplers to the current list.
  30372. * @param samplers defines the current sampler list.
  30373. */
  30374. static AddSamplers(samplers: string[]): void;
  30375. /**
  30376. * Add the required uniforms to the current buffer.
  30377. * @param uniformBuffer defines the current uniform buffer.
  30378. */
  30379. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30380. /**
  30381. * Makes a duplicate of the current instance into another one.
  30382. * @param detailMap define the instance where to copy the info
  30383. */
  30384. copyTo(detailMap: DetailMapConfiguration): void;
  30385. /**
  30386. * Serializes this detail map instance
  30387. * @returns - An object with the serialized instance.
  30388. */
  30389. serialize(): any;
  30390. /**
  30391. * Parses a detail map setting from a serialized object.
  30392. * @param source - Serialized object.
  30393. * @param scene Defines the scene we are parsing for
  30394. * @param rootUrl Defines the rootUrl to load from
  30395. */
  30396. parse(source: any, scene: Scene, rootUrl: string): void;
  30397. }
  30398. }
  30399. declare module BABYLON {
  30400. /** @hidden */
  30401. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30402. MAINUV1: boolean;
  30403. MAINUV2: boolean;
  30404. DIFFUSE: boolean;
  30405. DIFFUSEDIRECTUV: number;
  30406. DETAIL: boolean;
  30407. DETAILDIRECTUV: number;
  30408. DETAIL_NORMALBLENDMETHOD: number;
  30409. AMBIENT: boolean;
  30410. AMBIENTDIRECTUV: number;
  30411. OPACITY: boolean;
  30412. OPACITYDIRECTUV: number;
  30413. OPACITYRGB: boolean;
  30414. REFLECTION: boolean;
  30415. EMISSIVE: boolean;
  30416. EMISSIVEDIRECTUV: number;
  30417. SPECULAR: boolean;
  30418. SPECULARDIRECTUV: number;
  30419. BUMP: boolean;
  30420. BUMPDIRECTUV: number;
  30421. PARALLAX: boolean;
  30422. PARALLAXOCCLUSION: boolean;
  30423. SPECULAROVERALPHA: boolean;
  30424. CLIPPLANE: boolean;
  30425. CLIPPLANE2: boolean;
  30426. CLIPPLANE3: boolean;
  30427. CLIPPLANE4: boolean;
  30428. CLIPPLANE5: boolean;
  30429. CLIPPLANE6: boolean;
  30430. ALPHATEST: boolean;
  30431. DEPTHPREPASS: boolean;
  30432. ALPHAFROMDIFFUSE: boolean;
  30433. POINTSIZE: boolean;
  30434. FOG: boolean;
  30435. SPECULARTERM: boolean;
  30436. DIFFUSEFRESNEL: boolean;
  30437. OPACITYFRESNEL: boolean;
  30438. REFLECTIONFRESNEL: boolean;
  30439. REFRACTIONFRESNEL: boolean;
  30440. EMISSIVEFRESNEL: boolean;
  30441. FRESNEL: boolean;
  30442. NORMAL: boolean;
  30443. UV1: boolean;
  30444. UV2: boolean;
  30445. VERTEXCOLOR: boolean;
  30446. VERTEXALPHA: boolean;
  30447. NUM_BONE_INFLUENCERS: number;
  30448. BonesPerMesh: number;
  30449. BONETEXTURE: boolean;
  30450. INSTANCES: boolean;
  30451. THIN_INSTANCES: boolean;
  30452. GLOSSINESS: boolean;
  30453. ROUGHNESS: boolean;
  30454. EMISSIVEASILLUMINATION: boolean;
  30455. LINKEMISSIVEWITHDIFFUSE: boolean;
  30456. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30457. LIGHTMAP: boolean;
  30458. LIGHTMAPDIRECTUV: number;
  30459. OBJECTSPACE_NORMALMAP: boolean;
  30460. USELIGHTMAPASSHADOWMAP: boolean;
  30461. REFLECTIONMAP_3D: boolean;
  30462. REFLECTIONMAP_SPHERICAL: boolean;
  30463. REFLECTIONMAP_PLANAR: boolean;
  30464. REFLECTIONMAP_CUBIC: boolean;
  30465. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30466. REFLECTIONMAP_PROJECTION: boolean;
  30467. REFLECTIONMAP_SKYBOX: boolean;
  30468. REFLECTIONMAP_EXPLICIT: boolean;
  30469. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30470. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30471. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30472. INVERTCUBICMAP: boolean;
  30473. LOGARITHMICDEPTH: boolean;
  30474. REFRACTION: boolean;
  30475. REFRACTIONMAP_3D: boolean;
  30476. REFLECTIONOVERALPHA: boolean;
  30477. TWOSIDEDLIGHTING: boolean;
  30478. SHADOWFLOAT: boolean;
  30479. MORPHTARGETS: boolean;
  30480. MORPHTARGETS_NORMAL: boolean;
  30481. MORPHTARGETS_TANGENT: boolean;
  30482. MORPHTARGETS_UV: boolean;
  30483. NUM_MORPH_INFLUENCERS: number;
  30484. NONUNIFORMSCALING: boolean;
  30485. PREMULTIPLYALPHA: boolean;
  30486. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30487. ALPHABLEND: boolean;
  30488. PREPASS: boolean;
  30489. SCENE_MRT_COUNT: number;
  30490. RGBDLIGHTMAP: boolean;
  30491. RGBDREFLECTION: boolean;
  30492. RGBDREFRACTION: boolean;
  30493. IMAGEPROCESSING: boolean;
  30494. VIGNETTE: boolean;
  30495. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30496. VIGNETTEBLENDMODEOPAQUE: boolean;
  30497. TONEMAPPING: boolean;
  30498. TONEMAPPING_ACES: boolean;
  30499. CONTRAST: boolean;
  30500. COLORCURVES: boolean;
  30501. COLORGRADING: boolean;
  30502. COLORGRADING3D: boolean;
  30503. SAMPLER3DGREENDEPTH: boolean;
  30504. SAMPLER3DBGRMAP: boolean;
  30505. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30506. MULTIVIEW: boolean;
  30507. /**
  30508. * If the reflection texture on this material is in linear color space
  30509. * @hidden
  30510. */
  30511. IS_REFLECTION_LINEAR: boolean;
  30512. /**
  30513. * If the refraction texture on this material is in linear color space
  30514. * @hidden
  30515. */
  30516. IS_REFRACTION_LINEAR: boolean;
  30517. EXPOSURE: boolean;
  30518. constructor();
  30519. setReflectionMode(modeToEnable: string): void;
  30520. }
  30521. /**
  30522. * This is the default material used in Babylon. It is the best trade off between quality
  30523. * and performances.
  30524. * @see https://doc.babylonjs.com/babylon101/materials
  30525. */
  30526. export class StandardMaterial extends PushMaterial {
  30527. private _diffuseTexture;
  30528. /**
  30529. * The basic texture of the material as viewed under a light.
  30530. */
  30531. diffuseTexture: Nullable<BaseTexture>;
  30532. private _ambientTexture;
  30533. /**
  30534. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30535. */
  30536. ambientTexture: Nullable<BaseTexture>;
  30537. private _opacityTexture;
  30538. /**
  30539. * Define the transparency of the material from a texture.
  30540. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30541. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30542. */
  30543. opacityTexture: Nullable<BaseTexture>;
  30544. private _reflectionTexture;
  30545. /**
  30546. * Define the texture used to display the reflection.
  30547. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30548. */
  30549. reflectionTexture: Nullable<BaseTexture>;
  30550. private _emissiveTexture;
  30551. /**
  30552. * Define texture of the material as if self lit.
  30553. * This will be mixed in the final result even in the absence of light.
  30554. */
  30555. emissiveTexture: Nullable<BaseTexture>;
  30556. private _specularTexture;
  30557. /**
  30558. * Define how the color and intensity of the highlight given by the light in the material.
  30559. */
  30560. specularTexture: Nullable<BaseTexture>;
  30561. private _bumpTexture;
  30562. /**
  30563. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30564. * 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.
  30565. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30566. */
  30567. bumpTexture: Nullable<BaseTexture>;
  30568. private _lightmapTexture;
  30569. /**
  30570. * Complex lighting can be computationally expensive to compute at runtime.
  30571. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30572. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30573. */
  30574. lightmapTexture: Nullable<BaseTexture>;
  30575. private _refractionTexture;
  30576. /**
  30577. * Define the texture used to display the refraction.
  30578. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30579. */
  30580. refractionTexture: Nullable<BaseTexture>;
  30581. /**
  30582. * The color of the material lit by the environmental background lighting.
  30583. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30584. */
  30585. ambientColor: Color3;
  30586. /**
  30587. * The basic color of the material as viewed under a light.
  30588. */
  30589. diffuseColor: Color3;
  30590. /**
  30591. * Define how the color and intensity of the highlight given by the light in the material.
  30592. */
  30593. specularColor: Color3;
  30594. /**
  30595. * Define the color of the material as if self lit.
  30596. * This will be mixed in the final result even in the absence of light.
  30597. */
  30598. emissiveColor: Color3;
  30599. /**
  30600. * Defines how sharp are the highlights in the material.
  30601. * The bigger the value the sharper giving a more glossy feeling to the result.
  30602. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30603. */
  30604. specularPower: number;
  30605. private _useAlphaFromDiffuseTexture;
  30606. /**
  30607. * Does the transparency come from the diffuse texture alpha channel.
  30608. */
  30609. useAlphaFromDiffuseTexture: boolean;
  30610. private _useEmissiveAsIllumination;
  30611. /**
  30612. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30613. */
  30614. useEmissiveAsIllumination: boolean;
  30615. private _linkEmissiveWithDiffuse;
  30616. /**
  30617. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30618. * the emissive level when the final color is close to one.
  30619. */
  30620. linkEmissiveWithDiffuse: boolean;
  30621. private _useSpecularOverAlpha;
  30622. /**
  30623. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30624. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30625. */
  30626. useSpecularOverAlpha: boolean;
  30627. private _useReflectionOverAlpha;
  30628. /**
  30629. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30630. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30631. */
  30632. useReflectionOverAlpha: boolean;
  30633. private _disableLighting;
  30634. /**
  30635. * Does lights from the scene impacts this material.
  30636. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30637. */
  30638. disableLighting: boolean;
  30639. private _useObjectSpaceNormalMap;
  30640. /**
  30641. * Allows using an object space normal map (instead of tangent space).
  30642. */
  30643. useObjectSpaceNormalMap: boolean;
  30644. private _useParallax;
  30645. /**
  30646. * Is parallax enabled or not.
  30647. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30648. */
  30649. useParallax: boolean;
  30650. private _useParallaxOcclusion;
  30651. /**
  30652. * Is parallax occlusion enabled or not.
  30653. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30654. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30655. */
  30656. useParallaxOcclusion: boolean;
  30657. /**
  30658. * 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.
  30659. */
  30660. parallaxScaleBias: number;
  30661. private _roughness;
  30662. /**
  30663. * Helps to define how blurry the reflections should appears in the material.
  30664. */
  30665. roughness: number;
  30666. /**
  30667. * In case of refraction, define the value of the index of refraction.
  30668. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30669. */
  30670. indexOfRefraction: number;
  30671. /**
  30672. * Invert the refraction texture alongside the y axis.
  30673. * It can be useful with procedural textures or probe for instance.
  30674. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30675. */
  30676. invertRefractionY: boolean;
  30677. /**
  30678. * Defines the alpha limits in alpha test mode.
  30679. */
  30680. alphaCutOff: number;
  30681. private _useLightmapAsShadowmap;
  30682. /**
  30683. * In case of light mapping, define whether the map contains light or shadow informations.
  30684. */
  30685. useLightmapAsShadowmap: boolean;
  30686. private _diffuseFresnelParameters;
  30687. /**
  30688. * Define the diffuse fresnel parameters of the material.
  30689. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30690. */
  30691. diffuseFresnelParameters: FresnelParameters;
  30692. private _opacityFresnelParameters;
  30693. /**
  30694. * Define the opacity fresnel parameters of the material.
  30695. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30696. */
  30697. opacityFresnelParameters: FresnelParameters;
  30698. private _reflectionFresnelParameters;
  30699. /**
  30700. * Define the reflection fresnel parameters of the material.
  30701. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30702. */
  30703. reflectionFresnelParameters: FresnelParameters;
  30704. private _refractionFresnelParameters;
  30705. /**
  30706. * Define the refraction fresnel parameters of the material.
  30707. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30708. */
  30709. refractionFresnelParameters: FresnelParameters;
  30710. private _emissiveFresnelParameters;
  30711. /**
  30712. * Define the emissive fresnel parameters of the material.
  30713. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30714. */
  30715. emissiveFresnelParameters: FresnelParameters;
  30716. private _useReflectionFresnelFromSpecular;
  30717. /**
  30718. * If true automatically deducts the fresnels values from the material specularity.
  30719. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30720. */
  30721. useReflectionFresnelFromSpecular: boolean;
  30722. private _useGlossinessFromSpecularMapAlpha;
  30723. /**
  30724. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30725. */
  30726. useGlossinessFromSpecularMapAlpha: boolean;
  30727. private _maxSimultaneousLights;
  30728. /**
  30729. * Defines the maximum number of lights that can be used in the material
  30730. */
  30731. maxSimultaneousLights: number;
  30732. private _invertNormalMapX;
  30733. /**
  30734. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30735. */
  30736. invertNormalMapX: boolean;
  30737. private _invertNormalMapY;
  30738. /**
  30739. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30740. */
  30741. invertNormalMapY: boolean;
  30742. private _twoSidedLighting;
  30743. /**
  30744. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30745. */
  30746. twoSidedLighting: boolean;
  30747. /**
  30748. * Default configuration related to image processing available in the standard Material.
  30749. */
  30750. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30751. /**
  30752. * Gets the image processing configuration used either in this material.
  30753. */
  30754. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30755. /**
  30756. * Sets the Default image processing configuration used either in the this material.
  30757. *
  30758. * If sets to null, the scene one is in use.
  30759. */
  30760. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30761. /**
  30762. * Keep track of the image processing observer to allow dispose and replace.
  30763. */
  30764. private _imageProcessingObserver;
  30765. /**
  30766. * Attaches a new image processing configuration to the Standard Material.
  30767. * @param configuration
  30768. */
  30769. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30770. /**
  30771. * Gets wether the color curves effect is enabled.
  30772. */
  30773. get cameraColorCurvesEnabled(): boolean;
  30774. /**
  30775. * Sets wether the color curves effect is enabled.
  30776. */
  30777. set cameraColorCurvesEnabled(value: boolean);
  30778. /**
  30779. * Gets wether the color grading effect is enabled.
  30780. */
  30781. get cameraColorGradingEnabled(): boolean;
  30782. /**
  30783. * Gets wether the color grading effect is enabled.
  30784. */
  30785. set cameraColorGradingEnabled(value: boolean);
  30786. /**
  30787. * Gets wether tonemapping is enabled or not.
  30788. */
  30789. get cameraToneMappingEnabled(): boolean;
  30790. /**
  30791. * Sets wether tonemapping is enabled or not
  30792. */
  30793. set cameraToneMappingEnabled(value: boolean);
  30794. /**
  30795. * The camera exposure used on this material.
  30796. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30797. * This corresponds to a photographic exposure.
  30798. */
  30799. get cameraExposure(): number;
  30800. /**
  30801. * The camera exposure used on this material.
  30802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30803. * This corresponds to a photographic exposure.
  30804. */
  30805. set cameraExposure(value: number);
  30806. /**
  30807. * Gets The camera contrast used on this material.
  30808. */
  30809. get cameraContrast(): number;
  30810. /**
  30811. * Sets The camera contrast used on this material.
  30812. */
  30813. set cameraContrast(value: number);
  30814. /**
  30815. * Gets the Color Grading 2D Lookup Texture.
  30816. */
  30817. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30818. /**
  30819. * Sets the Color Grading 2D Lookup Texture.
  30820. */
  30821. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30822. /**
  30823. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30824. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30825. * 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;
  30826. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30827. */
  30828. get cameraColorCurves(): Nullable<ColorCurves>;
  30829. /**
  30830. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30831. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30832. * 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;
  30833. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30834. */
  30835. set cameraColorCurves(value: Nullable<ColorCurves>);
  30836. /**
  30837. * Can this material render to several textures at once
  30838. */
  30839. get canRenderToMRT(): boolean;
  30840. /**
  30841. * Defines the detail map parameters for the material.
  30842. */
  30843. readonly detailMap: DetailMapConfiguration;
  30844. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30845. protected _worldViewProjectionMatrix: Matrix;
  30846. protected _globalAmbientColor: Color3;
  30847. protected _useLogarithmicDepth: boolean;
  30848. protected _rebuildInParallel: boolean;
  30849. /**
  30850. * Instantiates a new standard material.
  30851. * This is the default material used in Babylon. It is the best trade off between quality
  30852. * and performances.
  30853. * @see https://doc.babylonjs.com/babylon101/materials
  30854. * @param name Define the name of the material in the scene
  30855. * @param scene Define the scene the material belong to
  30856. */
  30857. constructor(name: string, scene: Scene);
  30858. /**
  30859. * Gets a boolean indicating that current material needs to register RTT
  30860. */
  30861. get hasRenderTargetTextures(): boolean;
  30862. /**
  30863. * Gets the current class name of the material e.g. "StandardMaterial"
  30864. * Mainly use in serialization.
  30865. * @returns the class name
  30866. */
  30867. getClassName(): string;
  30868. /**
  30869. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30870. * You can try switching to logarithmic depth.
  30871. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30872. */
  30873. get useLogarithmicDepth(): boolean;
  30874. set useLogarithmicDepth(value: boolean);
  30875. /**
  30876. * Specifies if the material will require alpha blending
  30877. * @returns a boolean specifying if alpha blending is needed
  30878. */
  30879. needAlphaBlending(): boolean;
  30880. /**
  30881. * Specifies if this material should be rendered in alpha test mode
  30882. * @returns a boolean specifying if an alpha test is needed.
  30883. */
  30884. needAlphaTesting(): boolean;
  30885. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30886. /**
  30887. * Get the texture used for alpha test purpose.
  30888. * @returns the diffuse texture in case of the standard material.
  30889. */
  30890. getAlphaTestTexture(): Nullable<BaseTexture>;
  30891. /**
  30892. * Get if the submesh is ready to be used and all its information available.
  30893. * Child classes can use it to update shaders
  30894. * @param mesh defines the mesh to check
  30895. * @param subMesh defines which submesh to check
  30896. * @param useInstances specifies that instances should be used
  30897. * @returns a boolean indicating that the submesh is ready or not
  30898. */
  30899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30900. /**
  30901. * Builds the material UBO layouts.
  30902. * Used internally during the effect preparation.
  30903. */
  30904. buildUniformLayout(): void;
  30905. /**
  30906. * Unbinds the material from the mesh
  30907. */
  30908. unbind(): void;
  30909. /**
  30910. * Binds the submesh to this material by preparing the effect and shader to draw
  30911. * @param world defines the world transformation matrix
  30912. * @param mesh defines the mesh containing the submesh
  30913. * @param subMesh defines the submesh to bind the material to
  30914. */
  30915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30916. /**
  30917. * Get the list of animatables in the material.
  30918. * @returns the list of animatables object used in the material
  30919. */
  30920. getAnimatables(): IAnimatable[];
  30921. /**
  30922. * Gets the active textures from the material
  30923. * @returns an array of textures
  30924. */
  30925. getActiveTextures(): BaseTexture[];
  30926. /**
  30927. * Specifies if the material uses a texture
  30928. * @param texture defines the texture to check against the material
  30929. * @returns a boolean specifying if the material uses the texture
  30930. */
  30931. hasTexture(texture: BaseTexture): boolean;
  30932. /**
  30933. * Disposes the material
  30934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30936. */
  30937. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30938. /**
  30939. * Makes a duplicate of the material, and gives it a new name
  30940. * @param name defines the new name for the duplicated material
  30941. * @returns the cloned material
  30942. */
  30943. clone(name: string): StandardMaterial;
  30944. /**
  30945. * Serializes this material in a JSON representation
  30946. * @returns the serialized material object
  30947. */
  30948. serialize(): any;
  30949. /**
  30950. * Creates a standard material from parsed material data
  30951. * @param source defines the JSON representation of the material
  30952. * @param scene defines the hosting scene
  30953. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30954. * @returns a new standard material
  30955. */
  30956. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30957. /**
  30958. * Are diffuse textures enabled in the application.
  30959. */
  30960. static get DiffuseTextureEnabled(): boolean;
  30961. static set DiffuseTextureEnabled(value: boolean);
  30962. /**
  30963. * Are detail textures enabled in the application.
  30964. */
  30965. static get DetailTextureEnabled(): boolean;
  30966. static set DetailTextureEnabled(value: boolean);
  30967. /**
  30968. * Are ambient textures enabled in the application.
  30969. */
  30970. static get AmbientTextureEnabled(): boolean;
  30971. static set AmbientTextureEnabled(value: boolean);
  30972. /**
  30973. * Are opacity textures enabled in the application.
  30974. */
  30975. static get OpacityTextureEnabled(): boolean;
  30976. static set OpacityTextureEnabled(value: boolean);
  30977. /**
  30978. * Are reflection textures enabled in the application.
  30979. */
  30980. static get ReflectionTextureEnabled(): boolean;
  30981. static set ReflectionTextureEnabled(value: boolean);
  30982. /**
  30983. * Are emissive textures enabled in the application.
  30984. */
  30985. static get EmissiveTextureEnabled(): boolean;
  30986. static set EmissiveTextureEnabled(value: boolean);
  30987. /**
  30988. * Are specular textures enabled in the application.
  30989. */
  30990. static get SpecularTextureEnabled(): boolean;
  30991. static set SpecularTextureEnabled(value: boolean);
  30992. /**
  30993. * Are bump textures enabled in the application.
  30994. */
  30995. static get BumpTextureEnabled(): boolean;
  30996. static set BumpTextureEnabled(value: boolean);
  30997. /**
  30998. * Are lightmap textures enabled in the application.
  30999. */
  31000. static get LightmapTextureEnabled(): boolean;
  31001. static set LightmapTextureEnabled(value: boolean);
  31002. /**
  31003. * Are refraction textures enabled in the application.
  31004. */
  31005. static get RefractionTextureEnabled(): boolean;
  31006. static set RefractionTextureEnabled(value: boolean);
  31007. /**
  31008. * Are color grading textures enabled in the application.
  31009. */
  31010. static get ColorGradingTextureEnabled(): boolean;
  31011. static set ColorGradingTextureEnabled(value: boolean);
  31012. /**
  31013. * Are fresnels enabled in the application.
  31014. */
  31015. static get FresnelEnabled(): boolean;
  31016. static set FresnelEnabled(value: boolean);
  31017. }
  31018. }
  31019. declare module BABYLON {
  31020. /**
  31021. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31022. *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.
  31023. * The SPS is also a particle system. It provides some methods to manage the particles.
  31024. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31025. *
  31026. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31027. */
  31028. export class SolidParticleSystem implements IDisposable {
  31029. /**
  31030. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31031. * Example : var p = SPS.particles[i];
  31032. */
  31033. particles: SolidParticle[];
  31034. /**
  31035. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31036. */
  31037. nbParticles: number;
  31038. /**
  31039. * If the particles must ever face the camera (default false). Useful for planar particles.
  31040. */
  31041. billboard: boolean;
  31042. /**
  31043. * Recompute normals when adding a shape
  31044. */
  31045. recomputeNormals: boolean;
  31046. /**
  31047. * This a counter ofr your own usage. It's not set by any SPS functions.
  31048. */
  31049. counter: number;
  31050. /**
  31051. * The SPS name. This name is also given to the underlying mesh.
  31052. */
  31053. name: string;
  31054. /**
  31055. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31056. */
  31057. mesh: Mesh;
  31058. /**
  31059. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31060. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31061. */
  31062. vars: any;
  31063. /**
  31064. * This array is populated when the SPS is set as 'pickable'.
  31065. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31066. * Each element of this array is an object `{idx: int, faceId: int}`.
  31067. * `idx` is the picked particle index in the `SPS.particles` array
  31068. * `faceId` is the picked face index counted within this particle.
  31069. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31070. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31071. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31072. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31073. */
  31074. pickedParticles: {
  31075. idx: number;
  31076. faceId: number;
  31077. }[];
  31078. /**
  31079. * This array is populated when the SPS is set as 'pickable'
  31080. * Each key of this array is a submesh index.
  31081. * Each element of this array is a second array defined like this :
  31082. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31083. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31084. * `idx` is the picked particle index in the `SPS.particles` array
  31085. * `faceId` is the picked face index counted within this particle.
  31086. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31087. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31088. */
  31089. pickedBySubMesh: {
  31090. idx: number;
  31091. faceId: number;
  31092. }[][];
  31093. /**
  31094. * This array is populated when `enableDepthSort` is set to true.
  31095. * Each element of this array is an instance of the class DepthSortedParticle.
  31096. */
  31097. depthSortedParticles: DepthSortedParticle[];
  31098. /**
  31099. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31100. * @hidden
  31101. */
  31102. _bSphereOnly: boolean;
  31103. /**
  31104. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31105. * @hidden
  31106. */
  31107. _bSphereRadiusFactor: number;
  31108. private _scene;
  31109. private _positions;
  31110. private _indices;
  31111. private _normals;
  31112. private _colors;
  31113. private _uvs;
  31114. private _indices32;
  31115. private _positions32;
  31116. private _normals32;
  31117. private _fixedNormal32;
  31118. private _colors32;
  31119. private _uvs32;
  31120. private _index;
  31121. private _updatable;
  31122. private _pickable;
  31123. private _isVisibilityBoxLocked;
  31124. private _alwaysVisible;
  31125. private _depthSort;
  31126. private _expandable;
  31127. private _shapeCounter;
  31128. private _copy;
  31129. private _color;
  31130. private _computeParticleColor;
  31131. private _computeParticleTexture;
  31132. private _computeParticleRotation;
  31133. private _computeParticleVertex;
  31134. private _computeBoundingBox;
  31135. private _depthSortParticles;
  31136. private _camera;
  31137. private _mustUnrotateFixedNormals;
  31138. private _particlesIntersect;
  31139. private _needs32Bits;
  31140. private _isNotBuilt;
  31141. private _lastParticleId;
  31142. private _idxOfId;
  31143. private _multimaterialEnabled;
  31144. private _useModelMaterial;
  31145. private _indicesByMaterial;
  31146. private _materialIndexes;
  31147. private _depthSortFunction;
  31148. private _materialSortFunction;
  31149. private _materials;
  31150. private _multimaterial;
  31151. private _materialIndexesById;
  31152. private _defaultMaterial;
  31153. private _autoUpdateSubMeshes;
  31154. private _tmpVertex;
  31155. /**
  31156. * Creates a SPS (Solid Particle System) object.
  31157. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31158. * @param scene (Scene) is the scene in which the SPS is added.
  31159. * @param options defines the options of the sps e.g.
  31160. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31161. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31162. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31163. * * 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.
  31164. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31165. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31166. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31167. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31168. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31169. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31170. */
  31171. constructor(name: string, scene: Scene, options?: {
  31172. updatable?: boolean;
  31173. isPickable?: boolean;
  31174. enableDepthSort?: boolean;
  31175. particleIntersection?: boolean;
  31176. boundingSphereOnly?: boolean;
  31177. bSphereRadiusFactor?: number;
  31178. expandable?: boolean;
  31179. useModelMaterial?: boolean;
  31180. enableMultiMaterial?: boolean;
  31181. });
  31182. /**
  31183. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31184. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31185. * @returns the created mesh
  31186. */
  31187. buildMesh(): Mesh;
  31188. /**
  31189. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31190. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31191. * Thus the particles generated from `digest()` have their property `position` set yet.
  31192. * @param mesh ( Mesh ) is the mesh to be digested
  31193. * @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
  31194. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31195. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31196. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31197. * @returns the current SPS
  31198. */
  31199. digest(mesh: Mesh, options?: {
  31200. facetNb?: number;
  31201. number?: number;
  31202. delta?: number;
  31203. storage?: [];
  31204. }): SolidParticleSystem;
  31205. /**
  31206. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31207. * @hidden
  31208. */
  31209. private _unrotateFixedNormals;
  31210. /**
  31211. * Resets the temporary working copy particle
  31212. * @hidden
  31213. */
  31214. private _resetCopy;
  31215. /**
  31216. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31217. * @param p the current index in the positions array to be updated
  31218. * @param ind the current index in the indices array
  31219. * @param shape a Vector3 array, the shape geometry
  31220. * @param positions the positions array to be updated
  31221. * @param meshInd the shape indices array
  31222. * @param indices the indices array to be updated
  31223. * @param meshUV the shape uv array
  31224. * @param uvs the uv array to be updated
  31225. * @param meshCol the shape color array
  31226. * @param colors the color array to be updated
  31227. * @param meshNor the shape normals array
  31228. * @param normals the normals array to be updated
  31229. * @param idx the particle index
  31230. * @param idxInShape the particle index in its shape
  31231. * @param options the addShape() method passed options
  31232. * @model the particle model
  31233. * @hidden
  31234. */
  31235. private _meshBuilder;
  31236. /**
  31237. * Returns a shape Vector3 array from positions float array
  31238. * @param positions float array
  31239. * @returns a vector3 array
  31240. * @hidden
  31241. */
  31242. private _posToShape;
  31243. /**
  31244. * Returns a shapeUV array from a float uvs (array deep copy)
  31245. * @param uvs as a float array
  31246. * @returns a shapeUV array
  31247. * @hidden
  31248. */
  31249. private _uvsToShapeUV;
  31250. /**
  31251. * Adds a new particle object in the particles array
  31252. * @param idx particle index in particles array
  31253. * @param id particle id
  31254. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31255. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31256. * @param model particle ModelShape object
  31257. * @param shapeId model shape identifier
  31258. * @param idxInShape index of the particle in the current model
  31259. * @param bInfo model bounding info object
  31260. * @param storage target storage array, if any
  31261. * @hidden
  31262. */
  31263. private _addParticle;
  31264. /**
  31265. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31266. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31267. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31268. * @param nb (positive integer) the number of particles to be created from this model
  31269. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31270. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31271. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31272. * @returns the number of shapes in the system
  31273. */
  31274. addShape(mesh: Mesh, nb: number, options?: {
  31275. positionFunction?: any;
  31276. vertexFunction?: any;
  31277. storage?: [];
  31278. }): number;
  31279. /**
  31280. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31281. * @hidden
  31282. */
  31283. private _rebuildParticle;
  31284. /**
  31285. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31286. * @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.
  31287. * @returns the SPS.
  31288. */
  31289. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31290. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31291. * Returns an array with the removed particles.
  31292. * 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.
  31293. * The SPS can't be empty so at least one particle needs to remain in place.
  31294. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31295. * @param start index of the first particle to remove
  31296. * @param end index of the last particle to remove (included)
  31297. * @returns an array populated with the removed particles
  31298. */
  31299. removeParticles(start: number, end: number): SolidParticle[];
  31300. /**
  31301. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31302. * @param solidParticleArray an array populated with Solid Particles objects
  31303. * @returns the SPS
  31304. */
  31305. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31306. /**
  31307. * Creates a new particle and modifies the SPS mesh geometry :
  31308. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31309. * - calls _addParticle() to populate the particle array
  31310. * factorized code from addShape() and insertParticlesFromArray()
  31311. * @param idx particle index in the particles array
  31312. * @param i particle index in its shape
  31313. * @param modelShape particle ModelShape object
  31314. * @param shape shape vertex array
  31315. * @param meshInd shape indices array
  31316. * @param meshUV shape uv array
  31317. * @param meshCol shape color array
  31318. * @param meshNor shape normals array
  31319. * @param bbInfo shape bounding info
  31320. * @param storage target particle storage
  31321. * @options addShape() passed options
  31322. * @hidden
  31323. */
  31324. private _insertNewParticle;
  31325. /**
  31326. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31327. * This method calls `updateParticle()` for each particle of the SPS.
  31328. * For an animated SPS, it is usually called within the render loop.
  31329. * 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.
  31330. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31331. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31332. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31333. * @returns the SPS.
  31334. */
  31335. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31336. /**
  31337. * Disposes the SPS.
  31338. */
  31339. dispose(): void;
  31340. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31341. * idx is the particle index in the SPS
  31342. * faceId is the picked face index counted within this particle.
  31343. * Returns null if the pickInfo can't identify a picked particle.
  31344. * @param pickingInfo (PickingInfo object)
  31345. * @returns {idx: number, faceId: number} or null
  31346. */
  31347. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31348. idx: number;
  31349. faceId: number;
  31350. }>;
  31351. /**
  31352. * Returns a SolidParticle object from its identifier : particle.id
  31353. * @param id (integer) the particle Id
  31354. * @returns the searched particle or null if not found in the SPS.
  31355. */
  31356. getParticleById(id: number): Nullable<SolidParticle>;
  31357. /**
  31358. * Returns a new array populated with the particles having the passed shapeId.
  31359. * @param shapeId (integer) the shape identifier
  31360. * @returns a new solid particle array
  31361. */
  31362. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31363. /**
  31364. * Populates the passed array "ref" with the particles having the passed shapeId.
  31365. * @param shapeId the shape identifier
  31366. * @returns the SPS
  31367. * @param ref
  31368. */
  31369. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31370. /**
  31371. * Computes the required SubMeshes according the materials assigned to the particles.
  31372. * @returns the solid particle system.
  31373. * Does nothing if called before the SPS mesh is built.
  31374. */
  31375. computeSubMeshes(): SolidParticleSystem;
  31376. /**
  31377. * Sorts the solid particles by material when MultiMaterial is enabled.
  31378. * Updates the indices32 array.
  31379. * Updates the indicesByMaterial array.
  31380. * Updates the mesh indices array.
  31381. * @returns the SPS
  31382. * @hidden
  31383. */
  31384. private _sortParticlesByMaterial;
  31385. /**
  31386. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31387. * @hidden
  31388. */
  31389. private _setMaterialIndexesById;
  31390. /**
  31391. * Returns an array with unique values of Materials from the passed array
  31392. * @param array the material array to be checked and filtered
  31393. * @hidden
  31394. */
  31395. private _filterUniqueMaterialId;
  31396. /**
  31397. * Sets a new Standard Material as _defaultMaterial if not already set.
  31398. * @hidden
  31399. */
  31400. private _setDefaultMaterial;
  31401. /**
  31402. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31403. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31404. * @returns the SPS.
  31405. */
  31406. refreshVisibleSize(): SolidParticleSystem;
  31407. /**
  31408. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31409. * @param size the size (float) of the visibility box
  31410. * note : this doesn't lock the SPS mesh bounding box.
  31411. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31412. */
  31413. setVisibilityBox(size: number): void;
  31414. /**
  31415. * Gets whether the SPS as always visible or not
  31416. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31417. */
  31418. get isAlwaysVisible(): boolean;
  31419. /**
  31420. * Sets the SPS as always visible or not
  31421. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31422. */
  31423. set isAlwaysVisible(val: boolean);
  31424. /**
  31425. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31426. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31427. */
  31428. set isVisibilityBoxLocked(val: boolean);
  31429. /**
  31430. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31431. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31432. */
  31433. get isVisibilityBoxLocked(): boolean;
  31434. /**
  31435. * Tells to `setParticles()` to compute the particle rotations or not.
  31436. * Default value : true. The SPS is faster when it's set to false.
  31437. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31438. */
  31439. set computeParticleRotation(val: boolean);
  31440. /**
  31441. * Tells to `setParticles()` to compute the particle colors or not.
  31442. * Default value : true. The SPS is faster when it's set to false.
  31443. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31444. */
  31445. set computeParticleColor(val: boolean);
  31446. set computeParticleTexture(val: boolean);
  31447. /**
  31448. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31449. * Default value : false. The SPS is faster when it's set to false.
  31450. * Note : the particle custom vertex positions aren't stored values.
  31451. */
  31452. set computeParticleVertex(val: boolean);
  31453. /**
  31454. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31455. */
  31456. set computeBoundingBox(val: boolean);
  31457. /**
  31458. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31459. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31460. * Default : `true`
  31461. */
  31462. set depthSortParticles(val: boolean);
  31463. /**
  31464. * Gets if `setParticles()` computes the particle rotations or not.
  31465. * Default value : true. The SPS is faster when it's set to false.
  31466. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31467. */
  31468. get computeParticleRotation(): boolean;
  31469. /**
  31470. * Gets if `setParticles()` computes the particle colors or not.
  31471. * Default value : true. The SPS is faster when it's set to false.
  31472. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31473. */
  31474. get computeParticleColor(): boolean;
  31475. /**
  31476. * Gets if `setParticles()` computes the particle textures or not.
  31477. * Default value : true. The SPS is faster when it's set to false.
  31478. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31479. */
  31480. get computeParticleTexture(): boolean;
  31481. /**
  31482. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31483. * Default value : false. The SPS is faster when it's set to false.
  31484. * Note : the particle custom vertex positions aren't stored values.
  31485. */
  31486. get computeParticleVertex(): boolean;
  31487. /**
  31488. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31489. */
  31490. get computeBoundingBox(): boolean;
  31491. /**
  31492. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31493. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31494. * Default : `true`
  31495. */
  31496. get depthSortParticles(): boolean;
  31497. /**
  31498. * Gets if the SPS is created as expandable at construction time.
  31499. * Default : `false`
  31500. */
  31501. get expandable(): boolean;
  31502. /**
  31503. * Gets if the SPS supports the Multi Materials
  31504. */
  31505. get multimaterialEnabled(): boolean;
  31506. /**
  31507. * Gets if the SPS uses the model materials for its own multimaterial.
  31508. */
  31509. get useModelMaterial(): boolean;
  31510. /**
  31511. * The SPS used material array.
  31512. */
  31513. get materials(): Material[];
  31514. /**
  31515. * Sets the SPS MultiMaterial from the passed materials.
  31516. * Note : the passed array is internally copied and not used then by reference.
  31517. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31518. */
  31519. setMultiMaterial(materials: Material[]): void;
  31520. /**
  31521. * The SPS computed multimaterial object
  31522. */
  31523. get multimaterial(): MultiMaterial;
  31524. set multimaterial(mm: MultiMaterial);
  31525. /**
  31526. * If the subMeshes must be updated on the next call to setParticles()
  31527. */
  31528. get autoUpdateSubMeshes(): boolean;
  31529. set autoUpdateSubMeshes(val: boolean);
  31530. /**
  31531. * This function does nothing. It may be overwritten to set all the particle first values.
  31532. * The SPS doesn't call this function, you may have to call it by your own.
  31533. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31534. */
  31535. initParticles(): void;
  31536. /**
  31537. * This function does nothing. It may be overwritten to recycle a particle.
  31538. * The SPS doesn't call this function, you may have to call it by your own.
  31539. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31540. * @param particle The particle to recycle
  31541. * @returns the recycled particle
  31542. */
  31543. recycleParticle(particle: SolidParticle): SolidParticle;
  31544. /**
  31545. * Updates a particle : this function should be overwritten by the user.
  31546. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31547. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31548. * @example : just set a particle position or velocity and recycle conditions
  31549. * @param particle The particle to update
  31550. * @returns the updated particle
  31551. */
  31552. updateParticle(particle: SolidParticle): SolidParticle;
  31553. /**
  31554. * Updates a vertex of a particle : it can be overwritten by the user.
  31555. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31556. * @param particle the current particle
  31557. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31558. * @param pt the index of the current vertex in the particle shape
  31559. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31560. * @example : just set a vertex particle position or color
  31561. * @returns the sps
  31562. */
  31563. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31564. /**
  31565. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31566. * This does nothing and may be overwritten by the user.
  31567. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31568. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31569. * @param update the boolean update value actually passed to setParticles()
  31570. */
  31571. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31572. /**
  31573. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31574. * This will be passed three parameters.
  31575. * This does nothing and may be overwritten by the user.
  31576. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31577. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31578. * @param update the boolean update value actually passed to setParticles()
  31579. */
  31580. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31581. }
  31582. }
  31583. declare module BABYLON {
  31584. /**
  31585. * Represents one particle of a solid particle system.
  31586. */
  31587. export class SolidParticle {
  31588. /**
  31589. * particle global index
  31590. */
  31591. idx: number;
  31592. /**
  31593. * particle identifier
  31594. */
  31595. id: number;
  31596. /**
  31597. * The color of the particle
  31598. */
  31599. color: Nullable<Color4>;
  31600. /**
  31601. * The world space position of the particle.
  31602. */
  31603. position: Vector3;
  31604. /**
  31605. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31606. */
  31607. rotation: Vector3;
  31608. /**
  31609. * The world space rotation quaternion of the particle.
  31610. */
  31611. rotationQuaternion: Nullable<Quaternion>;
  31612. /**
  31613. * The scaling of the particle.
  31614. */
  31615. scaling: Vector3;
  31616. /**
  31617. * The uvs of the particle.
  31618. */
  31619. uvs: Vector4;
  31620. /**
  31621. * The current speed of the particle.
  31622. */
  31623. velocity: Vector3;
  31624. /**
  31625. * The pivot point in the particle local space.
  31626. */
  31627. pivot: Vector3;
  31628. /**
  31629. * Must the particle be translated from its pivot point in its local space ?
  31630. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31631. * Default : false
  31632. */
  31633. translateFromPivot: boolean;
  31634. /**
  31635. * Is the particle active or not ?
  31636. */
  31637. alive: boolean;
  31638. /**
  31639. * Is the particle visible or not ?
  31640. */
  31641. isVisible: boolean;
  31642. /**
  31643. * Index of this particle in the global "positions" array (Internal use)
  31644. * @hidden
  31645. */
  31646. _pos: number;
  31647. /**
  31648. * @hidden Index of this particle in the global "indices" array (Internal use)
  31649. */
  31650. _ind: number;
  31651. /**
  31652. * @hidden ModelShape of this particle (Internal use)
  31653. */
  31654. _model: ModelShape;
  31655. /**
  31656. * ModelShape id of this particle
  31657. */
  31658. shapeId: number;
  31659. /**
  31660. * Index of the particle in its shape id
  31661. */
  31662. idxInShape: number;
  31663. /**
  31664. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31665. */
  31666. _modelBoundingInfo: BoundingInfo;
  31667. /**
  31668. * @hidden Particle BoundingInfo object (Internal use)
  31669. */
  31670. _boundingInfo: BoundingInfo;
  31671. /**
  31672. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31673. */
  31674. _sps: SolidParticleSystem;
  31675. /**
  31676. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31677. */
  31678. _stillInvisible: boolean;
  31679. /**
  31680. * @hidden Last computed particle rotation matrix
  31681. */
  31682. _rotationMatrix: number[];
  31683. /**
  31684. * Parent particle Id, if any.
  31685. * Default null.
  31686. */
  31687. parentId: Nullable<number>;
  31688. /**
  31689. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31690. */
  31691. materialIndex: Nullable<number>;
  31692. /**
  31693. * Custom object or properties.
  31694. */
  31695. props: Nullable<any>;
  31696. /**
  31697. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31698. * The possible values are :
  31699. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31700. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31701. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31702. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31703. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31704. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31705. * */
  31706. cullingStrategy: number;
  31707. /**
  31708. * @hidden Internal global position in the SPS.
  31709. */
  31710. _globalPosition: Vector3;
  31711. /**
  31712. * Creates a Solid Particle object.
  31713. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31714. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31715. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31716. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31717. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31718. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31719. * @param shapeId (integer) is the model shape identifier in the SPS.
  31720. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31721. * @param sps defines the sps it is associated to
  31722. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31723. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31724. */
  31725. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31726. /**
  31727. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31728. * @param target the particle target
  31729. * @returns the current particle
  31730. */
  31731. copyToRef(target: SolidParticle): SolidParticle;
  31732. /**
  31733. * Legacy support, changed scale to scaling
  31734. */
  31735. get scale(): Vector3;
  31736. /**
  31737. * Legacy support, changed scale to scaling
  31738. */
  31739. set scale(scale: Vector3);
  31740. /**
  31741. * Legacy support, changed quaternion to rotationQuaternion
  31742. */
  31743. get quaternion(): Nullable<Quaternion>;
  31744. /**
  31745. * Legacy support, changed quaternion to rotationQuaternion
  31746. */
  31747. set quaternion(q: Nullable<Quaternion>);
  31748. /**
  31749. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31750. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31751. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31752. * @returns true if it intersects
  31753. */
  31754. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31755. /**
  31756. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31757. * A particle is in the frustum if its bounding box intersects the frustum
  31758. * @param frustumPlanes defines the frustum to test
  31759. * @returns true if the particle is in the frustum planes
  31760. */
  31761. isInFrustum(frustumPlanes: Plane[]): boolean;
  31762. /**
  31763. * get the rotation matrix of the particle
  31764. * @hidden
  31765. */
  31766. getRotationMatrix(m: Matrix): void;
  31767. }
  31768. /**
  31769. * Represents the shape of the model used by one particle of a solid particle system.
  31770. * SPS internal tool, don't use it manually.
  31771. */
  31772. export class ModelShape {
  31773. /**
  31774. * The shape id
  31775. * @hidden
  31776. */
  31777. shapeID: number;
  31778. /**
  31779. * flat array of model positions (internal use)
  31780. * @hidden
  31781. */
  31782. _shape: Vector3[];
  31783. /**
  31784. * flat array of model UVs (internal use)
  31785. * @hidden
  31786. */
  31787. _shapeUV: number[];
  31788. /**
  31789. * color array of the model
  31790. * @hidden
  31791. */
  31792. _shapeColors: number[];
  31793. /**
  31794. * indices array of the model
  31795. * @hidden
  31796. */
  31797. _indices: number[];
  31798. /**
  31799. * normals array of the model
  31800. * @hidden
  31801. */
  31802. _normals: number[];
  31803. /**
  31804. * length of the shape in the model indices array (internal use)
  31805. * @hidden
  31806. */
  31807. _indicesLength: number;
  31808. /**
  31809. * Custom position function (internal use)
  31810. * @hidden
  31811. */
  31812. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31813. /**
  31814. * Custom vertex function (internal use)
  31815. * @hidden
  31816. */
  31817. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31818. /**
  31819. * Model material (internal use)
  31820. * @hidden
  31821. */
  31822. _material: Nullable<Material>;
  31823. /**
  31824. * 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.
  31825. * SPS internal tool, don't use it manually.
  31826. * @hidden
  31827. */
  31828. 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>);
  31829. }
  31830. /**
  31831. * Represents a Depth Sorted Particle in the solid particle system.
  31832. * @hidden
  31833. */
  31834. export class DepthSortedParticle {
  31835. /**
  31836. * Particle index
  31837. */
  31838. idx: number;
  31839. /**
  31840. * Index of the particle in the "indices" array
  31841. */
  31842. ind: number;
  31843. /**
  31844. * Length of the particle shape in the "indices" array
  31845. */
  31846. indicesLength: number;
  31847. /**
  31848. * Squared distance from the particle to the camera
  31849. */
  31850. sqDistance: number;
  31851. /**
  31852. * Material index when used with MultiMaterials
  31853. */
  31854. materialIndex: number;
  31855. /**
  31856. * Creates a new sorted particle
  31857. * @param materialIndex
  31858. */
  31859. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31860. }
  31861. /**
  31862. * Represents a solid particle vertex
  31863. */
  31864. export class SolidParticleVertex {
  31865. /**
  31866. * Vertex position
  31867. */
  31868. position: Vector3;
  31869. /**
  31870. * Vertex color
  31871. */
  31872. color: Color4;
  31873. /**
  31874. * Vertex UV
  31875. */
  31876. uv: Vector2;
  31877. /**
  31878. * Creates a new solid particle vertex
  31879. */
  31880. constructor();
  31881. /** Vertex x coordinate */
  31882. get x(): number;
  31883. set x(val: number);
  31884. /** Vertex y coordinate */
  31885. get y(): number;
  31886. set y(val: number);
  31887. /** Vertex z coordinate */
  31888. get z(): number;
  31889. set z(val: number);
  31890. }
  31891. }
  31892. declare module BABYLON {
  31893. /**
  31894. * @hidden
  31895. */
  31896. export class _MeshCollisionData {
  31897. _checkCollisions: boolean;
  31898. _collisionMask: number;
  31899. _collisionGroup: number;
  31900. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31901. _collider: Nullable<Collider>;
  31902. _oldPositionForCollisions: Vector3;
  31903. _diffPositionForCollisions: Vector3;
  31904. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31905. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31906. }
  31907. }
  31908. declare module BABYLON {
  31909. /** @hidden */
  31910. class _FacetDataStorage {
  31911. facetPositions: Vector3[];
  31912. facetNormals: Vector3[];
  31913. facetPartitioning: number[][];
  31914. facetNb: number;
  31915. partitioningSubdivisions: number;
  31916. partitioningBBoxRatio: number;
  31917. facetDataEnabled: boolean;
  31918. facetParameters: any;
  31919. bbSize: Vector3;
  31920. subDiv: {
  31921. max: number;
  31922. X: number;
  31923. Y: number;
  31924. Z: number;
  31925. };
  31926. facetDepthSort: boolean;
  31927. facetDepthSortEnabled: boolean;
  31928. depthSortedIndices: IndicesArray;
  31929. depthSortedFacets: {
  31930. ind: number;
  31931. sqDistance: number;
  31932. }[];
  31933. facetDepthSortFunction: (f1: {
  31934. ind: number;
  31935. sqDistance: number;
  31936. }, f2: {
  31937. ind: number;
  31938. sqDistance: number;
  31939. }) => number;
  31940. facetDepthSortFrom: Vector3;
  31941. facetDepthSortOrigin: Vector3;
  31942. invertedMatrix: Matrix;
  31943. }
  31944. /**
  31945. * @hidden
  31946. **/
  31947. class _InternalAbstractMeshDataInfo {
  31948. _hasVertexAlpha: boolean;
  31949. _useVertexColors: boolean;
  31950. _numBoneInfluencers: number;
  31951. _applyFog: boolean;
  31952. _receiveShadows: boolean;
  31953. _facetData: _FacetDataStorage;
  31954. _visibility: number;
  31955. _skeleton: Nullable<Skeleton>;
  31956. _layerMask: number;
  31957. _computeBonesUsingShaders: boolean;
  31958. _isActive: boolean;
  31959. _onlyForInstances: boolean;
  31960. _isActiveIntermediate: boolean;
  31961. _onlyForInstancesIntermediate: boolean;
  31962. _actAsRegularMesh: boolean;
  31963. }
  31964. /**
  31965. * Class used to store all common mesh properties
  31966. */
  31967. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31968. /** No occlusion */
  31969. static OCCLUSION_TYPE_NONE: number;
  31970. /** Occlusion set to optimisitic */
  31971. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31972. /** Occlusion set to strict */
  31973. static OCCLUSION_TYPE_STRICT: number;
  31974. /** Use an accurante occlusion algorithm */
  31975. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31976. /** Use a conservative occlusion algorithm */
  31977. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31978. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31979. * Test order :
  31980. * Is the bounding sphere outside the frustum ?
  31981. * If not, are the bounding box vertices outside the frustum ?
  31982. * It not, then the cullable object is in the frustum.
  31983. */
  31984. static readonly CULLINGSTRATEGY_STANDARD: number;
  31985. /** Culling strategy : Bounding Sphere Only.
  31986. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31987. * It's also less accurate than the standard because some not visible objects can still be selected.
  31988. * Test : is the bounding sphere outside the frustum ?
  31989. * If not, then the cullable object is in the frustum.
  31990. */
  31991. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31992. /** Culling strategy : Optimistic Inclusion.
  31993. * This in an inclusion test first, then the standard exclusion test.
  31994. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31995. * 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.
  31996. * Anyway, it's as accurate as the standard strategy.
  31997. * Test :
  31998. * Is the cullable object bounding sphere center in the frustum ?
  31999. * If not, apply the default culling strategy.
  32000. */
  32001. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32002. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32003. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32004. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32005. * 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.
  32006. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32007. * Test :
  32008. * Is the cullable object bounding sphere center in the frustum ?
  32009. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32010. */
  32011. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32012. /**
  32013. * No billboard
  32014. */
  32015. static get BILLBOARDMODE_NONE(): number;
  32016. /** Billboard on X axis */
  32017. static get BILLBOARDMODE_X(): number;
  32018. /** Billboard on Y axis */
  32019. static get BILLBOARDMODE_Y(): number;
  32020. /** Billboard on Z axis */
  32021. static get BILLBOARDMODE_Z(): number;
  32022. /** Billboard on all axes */
  32023. static get BILLBOARDMODE_ALL(): number;
  32024. /** Billboard on using position instead of orientation */
  32025. static get BILLBOARDMODE_USE_POSITION(): number;
  32026. /** @hidden */
  32027. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32028. /**
  32029. * The culling strategy to use to check whether the mesh must be rendered or not.
  32030. * This value can be changed at any time and will be used on the next render mesh selection.
  32031. * The possible values are :
  32032. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32033. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32034. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32035. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32036. * Please read each static variable documentation to get details about the culling process.
  32037. * */
  32038. cullingStrategy: number;
  32039. /**
  32040. * Gets the number of facets in the mesh
  32041. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32042. */
  32043. get facetNb(): number;
  32044. /**
  32045. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32046. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32047. */
  32048. get partitioningSubdivisions(): number;
  32049. set partitioningSubdivisions(nb: number);
  32050. /**
  32051. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32052. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32053. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32054. */
  32055. get partitioningBBoxRatio(): number;
  32056. set partitioningBBoxRatio(ratio: number);
  32057. /**
  32058. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32059. * Works only for updatable meshes.
  32060. * Doesn't work with multi-materials
  32061. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32062. */
  32063. get mustDepthSortFacets(): boolean;
  32064. set mustDepthSortFacets(sort: boolean);
  32065. /**
  32066. * The location (Vector3) where the facet depth sort must be computed from.
  32067. * By default, the active camera position.
  32068. * Used only when facet depth sort is enabled
  32069. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32070. */
  32071. get facetDepthSortFrom(): Vector3;
  32072. set facetDepthSortFrom(location: Vector3);
  32073. /**
  32074. * gets a boolean indicating if facetData is enabled
  32075. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32076. */
  32077. get isFacetDataEnabled(): boolean;
  32078. /** @hidden */
  32079. _updateNonUniformScalingState(value: boolean): boolean;
  32080. /**
  32081. * An event triggered when this mesh collides with another one
  32082. */
  32083. onCollideObservable: Observable<AbstractMesh>;
  32084. /** Set a function to call when this mesh collides with another one */
  32085. set onCollide(callback: () => void);
  32086. /**
  32087. * An event triggered when the collision's position changes
  32088. */
  32089. onCollisionPositionChangeObservable: Observable<Vector3>;
  32090. /** Set a function to call when the collision's position changes */
  32091. set onCollisionPositionChange(callback: () => void);
  32092. /**
  32093. * An event triggered when material is changed
  32094. */
  32095. onMaterialChangedObservable: Observable<AbstractMesh>;
  32096. /**
  32097. * Gets or sets the orientation for POV movement & rotation
  32098. */
  32099. definedFacingForward: boolean;
  32100. /** @hidden */
  32101. _occlusionQuery: Nullable<WebGLQuery>;
  32102. /** @hidden */
  32103. _renderingGroup: Nullable<RenderingGroup>;
  32104. /**
  32105. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32106. */
  32107. get visibility(): number;
  32108. /**
  32109. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32110. */
  32111. set visibility(value: number);
  32112. /** Gets or sets the alpha index used to sort transparent meshes
  32113. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32114. */
  32115. alphaIndex: number;
  32116. /**
  32117. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32118. */
  32119. isVisible: boolean;
  32120. /**
  32121. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32122. */
  32123. isPickable: boolean;
  32124. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32125. showSubMeshesBoundingBox: boolean;
  32126. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32127. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32128. */
  32129. isBlocker: boolean;
  32130. /**
  32131. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32132. */
  32133. enablePointerMoveEvents: boolean;
  32134. private _renderingGroupId;
  32135. /**
  32136. * Specifies the rendering group id for this mesh (0 by default)
  32137. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32138. */
  32139. get renderingGroupId(): number;
  32140. set renderingGroupId(value: number);
  32141. private _material;
  32142. /** Gets or sets current material */
  32143. get material(): Nullable<Material>;
  32144. set material(value: Nullable<Material>);
  32145. /**
  32146. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32147. * @see https://doc.babylonjs.com/babylon101/shadows
  32148. */
  32149. get receiveShadows(): boolean;
  32150. set receiveShadows(value: boolean);
  32151. /** Defines color to use when rendering outline */
  32152. outlineColor: Color3;
  32153. /** Define width to use when rendering outline */
  32154. outlineWidth: number;
  32155. /** Defines color to use when rendering overlay */
  32156. overlayColor: Color3;
  32157. /** Defines alpha to use when rendering overlay */
  32158. overlayAlpha: number;
  32159. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32160. get hasVertexAlpha(): boolean;
  32161. set hasVertexAlpha(value: boolean);
  32162. /** 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) */
  32163. get useVertexColors(): boolean;
  32164. set useVertexColors(value: boolean);
  32165. /**
  32166. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32167. */
  32168. get computeBonesUsingShaders(): boolean;
  32169. set computeBonesUsingShaders(value: boolean);
  32170. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32171. get numBoneInfluencers(): number;
  32172. set numBoneInfluencers(value: number);
  32173. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32174. get applyFog(): boolean;
  32175. set applyFog(value: boolean);
  32176. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32177. useOctreeForRenderingSelection: boolean;
  32178. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32179. useOctreeForPicking: boolean;
  32180. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32181. useOctreeForCollisions: boolean;
  32182. /**
  32183. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32184. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32185. */
  32186. get layerMask(): number;
  32187. set layerMask(value: number);
  32188. /**
  32189. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32190. */
  32191. alwaysSelectAsActiveMesh: boolean;
  32192. /**
  32193. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32194. */
  32195. doNotSyncBoundingInfo: boolean;
  32196. /**
  32197. * Gets or sets the current action manager
  32198. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32199. */
  32200. actionManager: Nullable<AbstractActionManager>;
  32201. private _meshCollisionData;
  32202. /**
  32203. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32204. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32205. */
  32206. ellipsoid: Vector3;
  32207. /**
  32208. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32209. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32210. */
  32211. ellipsoidOffset: Vector3;
  32212. /**
  32213. * Gets or sets a collision mask used to mask collisions (default is -1).
  32214. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32215. */
  32216. get collisionMask(): number;
  32217. set collisionMask(mask: number);
  32218. /**
  32219. * Gets or sets the current collision group mask (-1 by default).
  32220. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32221. */
  32222. get collisionGroup(): number;
  32223. set collisionGroup(mask: number);
  32224. /**
  32225. * Gets or sets current surrounding meshes (null by default).
  32226. *
  32227. * By default collision detection is tested against every mesh in the scene.
  32228. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32229. * meshes will be tested for the collision.
  32230. *
  32231. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32232. */
  32233. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32234. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32235. /**
  32236. * Defines edge width used when edgesRenderer is enabled
  32237. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32238. */
  32239. edgesWidth: number;
  32240. /**
  32241. * Defines edge color used when edgesRenderer is enabled
  32242. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32243. */
  32244. edgesColor: Color4;
  32245. /** @hidden */
  32246. _edgesRenderer: Nullable<IEdgesRenderer>;
  32247. /** @hidden */
  32248. _masterMesh: Nullable<AbstractMesh>;
  32249. /** @hidden */
  32250. _boundingInfo: Nullable<BoundingInfo>;
  32251. /** @hidden */
  32252. _renderId: number;
  32253. /**
  32254. * Gets or sets the list of subMeshes
  32255. * @see https://doc.babylonjs.com/how_to/multi_materials
  32256. */
  32257. subMeshes: SubMesh[];
  32258. /** @hidden */
  32259. _intersectionsInProgress: AbstractMesh[];
  32260. /** @hidden */
  32261. _unIndexed: boolean;
  32262. /** @hidden */
  32263. _lightSources: Light[];
  32264. /** Gets the list of lights affecting that mesh */
  32265. get lightSources(): Light[];
  32266. /** @hidden */
  32267. get _positions(): Nullable<Vector3[]>;
  32268. /** @hidden */
  32269. _waitingData: {
  32270. lods: Nullable<any>;
  32271. actions: Nullable<any>;
  32272. freezeWorldMatrix: Nullable<boolean>;
  32273. };
  32274. /** @hidden */
  32275. _bonesTransformMatrices: Nullable<Float32Array>;
  32276. /** @hidden */
  32277. _transformMatrixTexture: Nullable<RawTexture>;
  32278. /**
  32279. * Gets or sets a skeleton to apply skining transformations
  32280. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32281. */
  32282. set skeleton(value: Nullable<Skeleton>);
  32283. get skeleton(): Nullable<Skeleton>;
  32284. /**
  32285. * An event triggered when the mesh is rebuilt.
  32286. */
  32287. onRebuildObservable: Observable<AbstractMesh>;
  32288. /**
  32289. * Creates a new AbstractMesh
  32290. * @param name defines the name of the mesh
  32291. * @param scene defines the hosting scene
  32292. */
  32293. constructor(name: string, scene?: Nullable<Scene>);
  32294. /**
  32295. * Returns the string "AbstractMesh"
  32296. * @returns "AbstractMesh"
  32297. */
  32298. getClassName(): string;
  32299. /**
  32300. * Gets a string representation of the current mesh
  32301. * @param fullDetails defines a boolean indicating if full details must be included
  32302. * @returns a string representation of the current mesh
  32303. */
  32304. toString(fullDetails?: boolean): string;
  32305. /**
  32306. * @hidden
  32307. */
  32308. protected _getEffectiveParent(): Nullable<Node>;
  32309. /** @hidden */
  32310. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32311. /** @hidden */
  32312. _rebuild(): void;
  32313. /** @hidden */
  32314. _resyncLightSources(): void;
  32315. /** @hidden */
  32316. _resyncLightSource(light: Light): void;
  32317. /** @hidden */
  32318. _unBindEffect(): void;
  32319. /** @hidden */
  32320. _removeLightSource(light: Light, dispose: boolean): void;
  32321. private _markSubMeshesAsDirty;
  32322. /** @hidden */
  32323. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32324. /** @hidden */
  32325. _markSubMeshesAsAttributesDirty(): void;
  32326. /** @hidden */
  32327. _markSubMeshesAsMiscDirty(): void;
  32328. /**
  32329. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32330. */
  32331. get scaling(): Vector3;
  32332. set scaling(newScaling: Vector3);
  32333. /**
  32334. * Returns true if the mesh is blocked. Implemented by child classes
  32335. */
  32336. get isBlocked(): boolean;
  32337. /**
  32338. * Returns the mesh itself by default. Implemented by child classes
  32339. * @param camera defines the camera to use to pick the right LOD level
  32340. * @returns the currentAbstractMesh
  32341. */
  32342. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32343. /**
  32344. * Returns 0 by default. Implemented by child classes
  32345. * @returns an integer
  32346. */
  32347. getTotalVertices(): number;
  32348. /**
  32349. * Returns a positive integer : the total number of indices in this mesh geometry.
  32350. * @returns the numner of indices or zero if the mesh has no geometry.
  32351. */
  32352. getTotalIndices(): number;
  32353. /**
  32354. * Returns null by default. Implemented by child classes
  32355. * @returns null
  32356. */
  32357. getIndices(): Nullable<IndicesArray>;
  32358. /**
  32359. * Returns the array of the requested vertex data kind. Implemented by child classes
  32360. * @param kind defines the vertex data kind to use
  32361. * @returns null
  32362. */
  32363. getVerticesData(kind: string): Nullable<FloatArray>;
  32364. /**
  32365. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32366. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32367. * Note that a new underlying VertexBuffer object is created each call.
  32368. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32369. * @param kind defines vertex data kind:
  32370. * * VertexBuffer.PositionKind
  32371. * * VertexBuffer.UVKind
  32372. * * VertexBuffer.UV2Kind
  32373. * * VertexBuffer.UV3Kind
  32374. * * VertexBuffer.UV4Kind
  32375. * * VertexBuffer.UV5Kind
  32376. * * VertexBuffer.UV6Kind
  32377. * * VertexBuffer.ColorKind
  32378. * * VertexBuffer.MatricesIndicesKind
  32379. * * VertexBuffer.MatricesIndicesExtraKind
  32380. * * VertexBuffer.MatricesWeightsKind
  32381. * * VertexBuffer.MatricesWeightsExtraKind
  32382. * @param data defines the data source
  32383. * @param updatable defines if the data must be flagged as updatable (or static)
  32384. * @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
  32385. * @returns the current mesh
  32386. */
  32387. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32388. /**
  32389. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32390. * If the mesh has no geometry, it is simply returned as it is.
  32391. * @param kind defines vertex data kind:
  32392. * * VertexBuffer.PositionKind
  32393. * * VertexBuffer.UVKind
  32394. * * VertexBuffer.UV2Kind
  32395. * * VertexBuffer.UV3Kind
  32396. * * VertexBuffer.UV4Kind
  32397. * * VertexBuffer.UV5Kind
  32398. * * VertexBuffer.UV6Kind
  32399. * * VertexBuffer.ColorKind
  32400. * * VertexBuffer.MatricesIndicesKind
  32401. * * VertexBuffer.MatricesIndicesExtraKind
  32402. * * VertexBuffer.MatricesWeightsKind
  32403. * * VertexBuffer.MatricesWeightsExtraKind
  32404. * @param data defines the data source
  32405. * @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
  32406. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32407. * @returns the current mesh
  32408. */
  32409. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32410. /**
  32411. * Sets the mesh indices,
  32412. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32413. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32414. * @param totalVertices Defines the total number of vertices
  32415. * @returns the current mesh
  32416. */
  32417. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32418. /**
  32419. * Gets a boolean indicating if specific vertex data is present
  32420. * @param kind defines the vertex data kind to use
  32421. * @returns true is data kind is present
  32422. */
  32423. isVerticesDataPresent(kind: string): boolean;
  32424. /**
  32425. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32426. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32427. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32428. * @returns a BoundingInfo
  32429. */
  32430. getBoundingInfo(): BoundingInfo;
  32431. /**
  32432. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32433. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32434. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32435. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32436. * @returns the current mesh
  32437. */
  32438. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32439. /**
  32440. * Overwrite the current bounding info
  32441. * @param boundingInfo defines the new bounding info
  32442. * @returns the current mesh
  32443. */
  32444. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32445. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32446. get useBones(): boolean;
  32447. /** @hidden */
  32448. _preActivate(): void;
  32449. /** @hidden */
  32450. _preActivateForIntermediateRendering(renderId: number): void;
  32451. /** @hidden */
  32452. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32453. /** @hidden */
  32454. _postActivate(): void;
  32455. /** @hidden */
  32456. _freeze(): void;
  32457. /** @hidden */
  32458. _unFreeze(): void;
  32459. /**
  32460. * Gets the current world matrix
  32461. * @returns a Matrix
  32462. */
  32463. getWorldMatrix(): Matrix;
  32464. /** @hidden */
  32465. _getWorldMatrixDeterminant(): number;
  32466. /**
  32467. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32468. */
  32469. get isAnInstance(): boolean;
  32470. /**
  32471. * Gets a boolean indicating if this mesh has instances
  32472. */
  32473. get hasInstances(): boolean;
  32474. /**
  32475. * Gets a boolean indicating if this mesh has thin instances
  32476. */
  32477. get hasThinInstances(): boolean;
  32478. /**
  32479. * Perform relative position change from the point of view of behind the front of the mesh.
  32480. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32481. * Supports definition of mesh facing forward or backward
  32482. * @param amountRight defines the distance on the right axis
  32483. * @param amountUp defines the distance on the up axis
  32484. * @param amountForward defines the distance on the forward axis
  32485. * @returns the current mesh
  32486. */
  32487. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32488. /**
  32489. * Calculate relative position change from the point of view of behind the front of the mesh.
  32490. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32491. * Supports definition of mesh facing forward or backward
  32492. * @param amountRight defines the distance on the right axis
  32493. * @param amountUp defines the distance on the up axis
  32494. * @param amountForward defines the distance on the forward axis
  32495. * @returns the new displacement vector
  32496. */
  32497. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32498. /**
  32499. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32500. * Supports definition of mesh facing forward or backward
  32501. * @param flipBack defines the flip
  32502. * @param twirlClockwise defines the twirl
  32503. * @param tiltRight defines the tilt
  32504. * @returns the current mesh
  32505. */
  32506. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32507. /**
  32508. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32509. * Supports definition of mesh facing forward or backward.
  32510. * @param flipBack defines the flip
  32511. * @param twirlClockwise defines the twirl
  32512. * @param tiltRight defines the tilt
  32513. * @returns the new rotation vector
  32514. */
  32515. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32516. /**
  32517. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32518. * This means the mesh underlying bounding box and sphere are recomputed.
  32519. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32520. * @returns the current mesh
  32521. */
  32522. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32523. /** @hidden */
  32524. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32525. /** @hidden */
  32526. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32527. /** @hidden */
  32528. _updateBoundingInfo(): AbstractMesh;
  32529. /** @hidden */
  32530. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32531. /** @hidden */
  32532. protected _afterComputeWorldMatrix(): void;
  32533. /** @hidden */
  32534. get _effectiveMesh(): AbstractMesh;
  32535. /**
  32536. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32537. * A mesh is in the frustum if its bounding box intersects the frustum
  32538. * @param frustumPlanes defines the frustum to test
  32539. * @returns true if the mesh is in the frustum planes
  32540. */
  32541. isInFrustum(frustumPlanes: Plane[]): boolean;
  32542. /**
  32543. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32544. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32545. * @param frustumPlanes defines the frustum to test
  32546. * @returns true if the mesh is completely in the frustum planes
  32547. */
  32548. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32549. /**
  32550. * True if the mesh intersects another mesh or a SolidParticle object
  32551. * @param mesh defines a target mesh or SolidParticle to test
  32552. * @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)
  32553. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32554. * @returns true if there is an intersection
  32555. */
  32556. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32557. /**
  32558. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32559. * @param point defines the point to test
  32560. * @returns true if there is an intersection
  32561. */
  32562. intersectsPoint(point: Vector3): boolean;
  32563. /**
  32564. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32565. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32566. */
  32567. get checkCollisions(): boolean;
  32568. set checkCollisions(collisionEnabled: boolean);
  32569. /**
  32570. * Gets Collider object used to compute collisions (not physics)
  32571. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32572. */
  32573. get collider(): Nullable<Collider>;
  32574. /**
  32575. * Move the mesh using collision engine
  32576. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32577. * @param displacement defines the requested displacement vector
  32578. * @returns the current mesh
  32579. */
  32580. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32581. private _onCollisionPositionChange;
  32582. /** @hidden */
  32583. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32584. /** @hidden */
  32585. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32586. /** @hidden */
  32587. _checkCollision(collider: Collider): AbstractMesh;
  32588. /** @hidden */
  32589. _generatePointsArray(): boolean;
  32590. /**
  32591. * Checks if the passed Ray intersects with the mesh
  32592. * @param ray defines the ray to use
  32593. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32594. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32595. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32596. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32597. * @returns the picking info
  32598. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32599. */
  32600. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32601. /**
  32602. * Clones the current mesh
  32603. * @param name defines the mesh name
  32604. * @param newParent defines the new mesh parent
  32605. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32606. * @returns the new mesh
  32607. */
  32608. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32609. /**
  32610. * Disposes all the submeshes of the current meshnp
  32611. * @returns the current mesh
  32612. */
  32613. releaseSubMeshes(): AbstractMesh;
  32614. /**
  32615. * Releases resources associated with this abstract mesh.
  32616. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32617. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32618. */
  32619. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32620. /**
  32621. * Adds the passed mesh as a child to the current mesh
  32622. * @param mesh defines the child mesh
  32623. * @returns the current mesh
  32624. */
  32625. addChild(mesh: AbstractMesh): AbstractMesh;
  32626. /**
  32627. * Removes the passed mesh from the current mesh children list
  32628. * @param mesh defines the child mesh
  32629. * @returns the current mesh
  32630. */
  32631. removeChild(mesh: AbstractMesh): AbstractMesh;
  32632. /** @hidden */
  32633. private _initFacetData;
  32634. /**
  32635. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32636. * This method can be called within the render loop.
  32637. * 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
  32638. * @returns the current mesh
  32639. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32640. */
  32641. updateFacetData(): AbstractMesh;
  32642. /**
  32643. * Returns the facetLocalNormals array.
  32644. * The normals are expressed in the mesh local spac
  32645. * @returns an array of Vector3
  32646. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32647. */
  32648. getFacetLocalNormals(): Vector3[];
  32649. /**
  32650. * Returns the facetLocalPositions array.
  32651. * The facet positions are expressed in the mesh local space
  32652. * @returns an array of Vector3
  32653. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32654. */
  32655. getFacetLocalPositions(): Vector3[];
  32656. /**
  32657. * Returns the facetLocalPartioning array
  32658. * @returns an array of array of numbers
  32659. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32660. */
  32661. getFacetLocalPartitioning(): number[][];
  32662. /**
  32663. * Returns the i-th facet position in the world system.
  32664. * This method allocates a new Vector3 per call
  32665. * @param i defines the facet index
  32666. * @returns a new Vector3
  32667. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32668. */
  32669. getFacetPosition(i: number): Vector3;
  32670. /**
  32671. * Sets the reference Vector3 with the i-th facet position in the world system
  32672. * @param i defines the facet index
  32673. * @param ref defines the target vector
  32674. * @returns the current mesh
  32675. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32676. */
  32677. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32678. /**
  32679. * Returns the i-th facet normal in the world system.
  32680. * This method allocates a new Vector3 per call
  32681. * @param i defines the facet index
  32682. * @returns a new Vector3
  32683. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32684. */
  32685. getFacetNormal(i: number): Vector3;
  32686. /**
  32687. * Sets the reference Vector3 with the i-th facet normal in the world system
  32688. * @param i defines the facet index
  32689. * @param ref defines the target vector
  32690. * @returns the current mesh
  32691. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32692. */
  32693. getFacetNormalToRef(i: number, ref: Vector3): this;
  32694. /**
  32695. * 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)
  32696. * @param x defines x coordinate
  32697. * @param y defines y coordinate
  32698. * @param z defines z coordinate
  32699. * @returns the array of facet indexes
  32700. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32701. */
  32702. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32703. /**
  32704. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32705. * @param projected sets as the (x,y,z) world projection on the facet
  32706. * @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
  32707. * @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
  32708. * @param x defines x coordinate
  32709. * @param y defines y coordinate
  32710. * @param z defines z coordinate
  32711. * @returns the face index if found (or null instead)
  32712. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32713. */
  32714. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32715. /**
  32716. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32717. * @param projected sets as the (x,y,z) local projection on the facet
  32718. * @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
  32719. * @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
  32720. * @param x defines x coordinate
  32721. * @param y defines y coordinate
  32722. * @param z defines z coordinate
  32723. * @returns the face index if found (or null instead)
  32724. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32725. */
  32726. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32727. /**
  32728. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32729. * @returns the parameters
  32730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32731. */
  32732. getFacetDataParameters(): any;
  32733. /**
  32734. * Disables the feature FacetData and frees the related memory
  32735. * @returns the current mesh
  32736. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32737. */
  32738. disableFacetData(): AbstractMesh;
  32739. /**
  32740. * Updates the AbstractMesh indices array
  32741. * @param indices defines the data source
  32742. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32743. * @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)
  32744. * @returns the current mesh
  32745. */
  32746. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32747. /**
  32748. * Creates new normals data for the mesh
  32749. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32750. * @returns the current mesh
  32751. */
  32752. createNormals(updatable: boolean): AbstractMesh;
  32753. /**
  32754. * Align the mesh with a normal
  32755. * @param normal defines the normal to use
  32756. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32757. * @returns the current mesh
  32758. */
  32759. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32760. /** @hidden */
  32761. _checkOcclusionQuery(): boolean;
  32762. /**
  32763. * Disables the mesh edge rendering mode
  32764. * @returns the currentAbstractMesh
  32765. */
  32766. disableEdgesRendering(): AbstractMesh;
  32767. /**
  32768. * Enables the edge rendering mode on the mesh.
  32769. * This mode makes the mesh edges visible
  32770. * @param epsilon defines the maximal distance between two angles to detect a face
  32771. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32772. * @returns the currentAbstractMesh
  32773. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32774. */
  32775. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32776. /**
  32777. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32778. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32779. */
  32780. getConnectedParticleSystems(): IParticleSystem[];
  32781. }
  32782. }
  32783. declare module BABYLON {
  32784. /**
  32785. * Interface used to define ActionEvent
  32786. */
  32787. export interface IActionEvent {
  32788. /** The mesh or sprite that triggered the action */
  32789. source: any;
  32790. /** The X mouse cursor position at the time of the event */
  32791. pointerX: number;
  32792. /** The Y mouse cursor position at the time of the event */
  32793. pointerY: number;
  32794. /** The mesh that is currently pointed at (can be null) */
  32795. meshUnderPointer: Nullable<AbstractMesh>;
  32796. /** the original (browser) event that triggered the ActionEvent */
  32797. sourceEvent?: any;
  32798. /** additional data for the event */
  32799. additionalData?: any;
  32800. }
  32801. /**
  32802. * ActionEvent is the event being sent when an action is triggered.
  32803. */
  32804. export class ActionEvent implements IActionEvent {
  32805. /** The mesh or sprite that triggered the action */
  32806. source: any;
  32807. /** The X mouse cursor position at the time of the event */
  32808. pointerX: number;
  32809. /** The Y mouse cursor position at the time of the event */
  32810. pointerY: number;
  32811. /** The mesh that is currently pointed at (can be null) */
  32812. meshUnderPointer: Nullable<AbstractMesh>;
  32813. /** the original (browser) event that triggered the ActionEvent */
  32814. sourceEvent?: any;
  32815. /** additional data for the event */
  32816. additionalData?: any;
  32817. /**
  32818. * Creates a new ActionEvent
  32819. * @param source The mesh or sprite that triggered the action
  32820. * @param pointerX The X mouse cursor position at the time of the event
  32821. * @param pointerY The Y mouse cursor position at the time of the event
  32822. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32823. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32824. * @param additionalData additional data for the event
  32825. */
  32826. constructor(
  32827. /** The mesh or sprite that triggered the action */
  32828. source: any,
  32829. /** The X mouse cursor position at the time of the event */
  32830. pointerX: number,
  32831. /** The Y mouse cursor position at the time of the event */
  32832. pointerY: number,
  32833. /** The mesh that is currently pointed at (can be null) */
  32834. meshUnderPointer: Nullable<AbstractMesh>,
  32835. /** the original (browser) event that triggered the ActionEvent */
  32836. sourceEvent?: any,
  32837. /** additional data for the event */
  32838. additionalData?: any);
  32839. /**
  32840. * Helper function to auto-create an ActionEvent from a source mesh.
  32841. * @param source The source mesh that triggered the event
  32842. * @param evt The original (browser) event
  32843. * @param additionalData additional data for the event
  32844. * @returns the new ActionEvent
  32845. */
  32846. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32847. /**
  32848. * Helper function to auto-create an ActionEvent from a source sprite
  32849. * @param source The source sprite that triggered the event
  32850. * @param scene Scene associated with the sprite
  32851. * @param evt The original (browser) event
  32852. * @param additionalData additional data for the event
  32853. * @returns the new ActionEvent
  32854. */
  32855. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32856. /**
  32857. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32858. * @param scene the scene where the event occurred
  32859. * @param evt The original (browser) event
  32860. * @returns the new ActionEvent
  32861. */
  32862. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32863. /**
  32864. * Helper function to auto-create an ActionEvent from a primitive
  32865. * @param prim defines the target primitive
  32866. * @param pointerPos defines the pointer position
  32867. * @param evt The original (browser) event
  32868. * @param additionalData additional data for the event
  32869. * @returns the new ActionEvent
  32870. */
  32871. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32872. }
  32873. }
  32874. declare module BABYLON {
  32875. /**
  32876. * Abstract class used to decouple action Manager from scene and meshes.
  32877. * Do not instantiate.
  32878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32879. */
  32880. export abstract class AbstractActionManager implements IDisposable {
  32881. /** Gets the list of active triggers */
  32882. static Triggers: {
  32883. [key: string]: number;
  32884. };
  32885. /** Gets the cursor to use when hovering items */
  32886. hoverCursor: string;
  32887. /** Gets the list of actions */
  32888. actions: IAction[];
  32889. /**
  32890. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32891. */
  32892. isRecursive: boolean;
  32893. /**
  32894. * Releases all associated resources
  32895. */
  32896. abstract dispose(): void;
  32897. /**
  32898. * Does this action manager has pointer triggers
  32899. */
  32900. abstract get hasPointerTriggers(): boolean;
  32901. /**
  32902. * Does this action manager has pick triggers
  32903. */
  32904. abstract get hasPickTriggers(): boolean;
  32905. /**
  32906. * Process a specific trigger
  32907. * @param trigger defines the trigger to process
  32908. * @param evt defines the event details to be processed
  32909. */
  32910. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32911. /**
  32912. * Does this action manager handles actions of any of the given triggers
  32913. * @param triggers defines the triggers to be tested
  32914. * @return a boolean indicating whether one (or more) of the triggers is handled
  32915. */
  32916. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32917. /**
  32918. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32919. * speed.
  32920. * @param triggerA defines the trigger to be tested
  32921. * @param triggerB defines the trigger to be tested
  32922. * @return a boolean indicating whether one (or more) of the triggers is handled
  32923. */
  32924. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32925. /**
  32926. * Does this action manager handles actions of a given trigger
  32927. * @param trigger defines the trigger to be tested
  32928. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32929. * @return whether the trigger is handled
  32930. */
  32931. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32932. /**
  32933. * Serialize this manager to a JSON object
  32934. * @param name defines the property name to store this manager
  32935. * @returns a JSON representation of this manager
  32936. */
  32937. abstract serialize(name: string): any;
  32938. /**
  32939. * Registers an action to this action manager
  32940. * @param action defines the action to be registered
  32941. * @return the action amended (prepared) after registration
  32942. */
  32943. abstract registerAction(action: IAction): Nullable<IAction>;
  32944. /**
  32945. * Unregisters an action to this action manager
  32946. * @param action defines the action to be unregistered
  32947. * @return a boolean indicating whether the action has been unregistered
  32948. */
  32949. abstract unregisterAction(action: IAction): Boolean;
  32950. /**
  32951. * Does exist one action manager with at least one trigger
  32952. **/
  32953. static get HasTriggers(): boolean;
  32954. /**
  32955. * Does exist one action manager with at least one pick trigger
  32956. **/
  32957. static get HasPickTriggers(): boolean;
  32958. /**
  32959. * Does exist one action manager that handles actions of a given trigger
  32960. * @param trigger defines the trigger to be tested
  32961. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32962. **/
  32963. static HasSpecificTrigger(trigger: number): boolean;
  32964. }
  32965. }
  32966. declare module BABYLON {
  32967. /**
  32968. * Defines how a node can be built from a string name.
  32969. */
  32970. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32971. /**
  32972. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32973. */
  32974. export class Node implements IBehaviorAware<Node> {
  32975. /** @hidden */
  32976. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32977. private static _NodeConstructors;
  32978. /**
  32979. * Add a new node constructor
  32980. * @param type defines the type name of the node to construct
  32981. * @param constructorFunc defines the constructor function
  32982. */
  32983. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32984. /**
  32985. * Returns a node constructor based on type name
  32986. * @param type defines the type name
  32987. * @param name defines the new node name
  32988. * @param scene defines the hosting scene
  32989. * @param options defines optional options to transmit to constructors
  32990. * @returns the new constructor or null
  32991. */
  32992. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32993. /**
  32994. * Gets or sets the name of the node
  32995. */
  32996. name: string;
  32997. /**
  32998. * Gets or sets the id of the node
  32999. */
  33000. id: string;
  33001. /**
  33002. * Gets or sets the unique id of the node
  33003. */
  33004. uniqueId: number;
  33005. /**
  33006. * Gets or sets a string used to store user defined state for the node
  33007. */
  33008. state: string;
  33009. /**
  33010. * Gets or sets an object used to store user defined information for the node
  33011. */
  33012. metadata: any;
  33013. /**
  33014. * For internal use only. Please do not use.
  33015. */
  33016. reservedDataStore: any;
  33017. /**
  33018. * List of inspectable custom properties (used by the Inspector)
  33019. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33020. */
  33021. inspectableCustomProperties: IInspectable[];
  33022. private _doNotSerialize;
  33023. /**
  33024. * Gets or sets a boolean used to define if the node must be serialized
  33025. */
  33026. get doNotSerialize(): boolean;
  33027. set doNotSerialize(value: boolean);
  33028. /** @hidden */
  33029. _isDisposed: boolean;
  33030. /**
  33031. * Gets a list of Animations associated with the node
  33032. */
  33033. animations: Animation[];
  33034. protected _ranges: {
  33035. [name: string]: Nullable<AnimationRange>;
  33036. };
  33037. /**
  33038. * Callback raised when the node is ready to be used
  33039. */
  33040. onReady: Nullable<(node: Node) => void>;
  33041. private _isEnabled;
  33042. private _isParentEnabled;
  33043. private _isReady;
  33044. /** @hidden */
  33045. _currentRenderId: number;
  33046. private _parentUpdateId;
  33047. /** @hidden */
  33048. _childUpdateId: number;
  33049. /** @hidden */
  33050. _waitingParentId: Nullable<string>;
  33051. /** @hidden */
  33052. _scene: Scene;
  33053. /** @hidden */
  33054. _cache: any;
  33055. private _parentNode;
  33056. private _children;
  33057. /** @hidden */
  33058. _worldMatrix: Matrix;
  33059. /** @hidden */
  33060. _worldMatrixDeterminant: number;
  33061. /** @hidden */
  33062. _worldMatrixDeterminantIsDirty: boolean;
  33063. /** @hidden */
  33064. private _sceneRootNodesIndex;
  33065. /**
  33066. * Gets a boolean indicating if the node has been disposed
  33067. * @returns true if the node was disposed
  33068. */
  33069. isDisposed(): boolean;
  33070. /**
  33071. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33072. * @see https://doc.babylonjs.com/how_to/parenting
  33073. */
  33074. set parent(parent: Nullable<Node>);
  33075. get parent(): Nullable<Node>;
  33076. /** @hidden */
  33077. _addToSceneRootNodes(): void;
  33078. /** @hidden */
  33079. _removeFromSceneRootNodes(): void;
  33080. private _animationPropertiesOverride;
  33081. /**
  33082. * Gets or sets the animation properties override
  33083. */
  33084. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33085. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33086. /**
  33087. * Gets a string identifying the name of the class
  33088. * @returns "Node" string
  33089. */
  33090. getClassName(): string;
  33091. /** @hidden */
  33092. readonly _isNode: boolean;
  33093. /**
  33094. * An event triggered when the mesh is disposed
  33095. */
  33096. onDisposeObservable: Observable<Node>;
  33097. private _onDisposeObserver;
  33098. /**
  33099. * Sets a callback that will be raised when the node will be disposed
  33100. */
  33101. set onDispose(callback: () => void);
  33102. /**
  33103. * Creates a new Node
  33104. * @param name the name and id to be given to this node
  33105. * @param scene the scene this node will be added to
  33106. */
  33107. constructor(name: string, scene?: Nullable<Scene>);
  33108. /**
  33109. * Gets the scene of the node
  33110. * @returns a scene
  33111. */
  33112. getScene(): Scene;
  33113. /**
  33114. * Gets the engine of the node
  33115. * @returns a Engine
  33116. */
  33117. getEngine(): Engine;
  33118. private _behaviors;
  33119. /**
  33120. * Attach a behavior to the node
  33121. * @see https://doc.babylonjs.com/features/behaviour
  33122. * @param behavior defines the behavior to attach
  33123. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33124. * @returns the current Node
  33125. */
  33126. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33127. /**
  33128. * Remove an attached behavior
  33129. * @see https://doc.babylonjs.com/features/behaviour
  33130. * @param behavior defines the behavior to attach
  33131. * @returns the current Node
  33132. */
  33133. removeBehavior(behavior: Behavior<Node>): Node;
  33134. /**
  33135. * Gets the list of attached behaviors
  33136. * @see https://doc.babylonjs.com/features/behaviour
  33137. */
  33138. get behaviors(): Behavior<Node>[];
  33139. /**
  33140. * Gets an attached behavior by name
  33141. * @param name defines the name of the behavior to look for
  33142. * @see https://doc.babylonjs.com/features/behaviour
  33143. * @returns null if behavior was not found else the requested behavior
  33144. */
  33145. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33146. /**
  33147. * Returns the latest update of the World matrix
  33148. * @returns a Matrix
  33149. */
  33150. getWorldMatrix(): Matrix;
  33151. /** @hidden */
  33152. _getWorldMatrixDeterminant(): number;
  33153. /**
  33154. * Returns directly the latest state of the mesh World matrix.
  33155. * A Matrix is returned.
  33156. */
  33157. get worldMatrixFromCache(): Matrix;
  33158. /** @hidden */
  33159. _initCache(): void;
  33160. /** @hidden */
  33161. updateCache(force?: boolean): void;
  33162. /** @hidden */
  33163. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33164. /** @hidden */
  33165. _updateCache(ignoreParentClass?: boolean): void;
  33166. /** @hidden */
  33167. _isSynchronized(): boolean;
  33168. /** @hidden */
  33169. _markSyncedWithParent(): void;
  33170. /** @hidden */
  33171. isSynchronizedWithParent(): boolean;
  33172. /** @hidden */
  33173. isSynchronized(): boolean;
  33174. /**
  33175. * Is this node ready to be used/rendered
  33176. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33177. * @return true if the node is ready
  33178. */
  33179. isReady(completeCheck?: boolean): boolean;
  33180. /**
  33181. * Is this node enabled?
  33182. * 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
  33183. * @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
  33184. * @return whether this node (and its parent) is enabled
  33185. */
  33186. isEnabled(checkAncestors?: boolean): boolean;
  33187. /** @hidden */
  33188. protected _syncParentEnabledState(): void;
  33189. /**
  33190. * Set the enabled state of this node
  33191. * @param value defines the new enabled state
  33192. */
  33193. setEnabled(value: boolean): void;
  33194. /**
  33195. * Is this node a descendant of the given node?
  33196. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33197. * @param ancestor defines the parent node to inspect
  33198. * @returns a boolean indicating if this node is a descendant of the given node
  33199. */
  33200. isDescendantOf(ancestor: Node): boolean;
  33201. /** @hidden */
  33202. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33203. /**
  33204. * Will return all nodes that have this node as ascendant
  33205. * @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
  33206. * @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
  33207. * @return all children nodes of all types
  33208. */
  33209. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33210. /**
  33211. * Get all child-meshes of this node
  33212. * @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)
  33213. * @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
  33214. * @returns an array of AbstractMesh
  33215. */
  33216. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33217. /**
  33218. * Get all direct children of this node
  33219. * @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
  33220. * @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)
  33221. * @returns an array of Node
  33222. */
  33223. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33224. /** @hidden */
  33225. _setReady(state: boolean): void;
  33226. /**
  33227. * Get an animation by name
  33228. * @param name defines the name of the animation to look for
  33229. * @returns null if not found else the requested animation
  33230. */
  33231. getAnimationByName(name: string): Nullable<Animation>;
  33232. /**
  33233. * Creates an animation range for this node
  33234. * @param name defines the name of the range
  33235. * @param from defines the starting key
  33236. * @param to defines the end key
  33237. */
  33238. createAnimationRange(name: string, from: number, to: number): void;
  33239. /**
  33240. * Delete a specific animation range
  33241. * @param name defines the name of the range to delete
  33242. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33243. */
  33244. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33245. /**
  33246. * Get an animation range by name
  33247. * @param name defines the name of the animation range to look for
  33248. * @returns null if not found else the requested animation range
  33249. */
  33250. getAnimationRange(name: string): Nullable<AnimationRange>;
  33251. /**
  33252. * Gets the list of all animation ranges defined on this node
  33253. * @returns an array
  33254. */
  33255. getAnimationRanges(): Nullable<AnimationRange>[];
  33256. /**
  33257. * Will start the animation sequence
  33258. * @param name defines the range frames for animation sequence
  33259. * @param loop defines if the animation should loop (false by default)
  33260. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33261. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33262. * @returns the object created for this animation. If range does not exist, it will return null
  33263. */
  33264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33265. /**
  33266. * Serialize animation ranges into a JSON compatible object
  33267. * @returns serialization object
  33268. */
  33269. serializeAnimationRanges(): any;
  33270. /**
  33271. * Computes the world matrix of the node
  33272. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33273. * @returns the world matrix
  33274. */
  33275. computeWorldMatrix(force?: boolean): Matrix;
  33276. /**
  33277. * Releases resources associated with this node.
  33278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33280. */
  33281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33282. /**
  33283. * Parse animation range data from a serialization object and store them into a given node
  33284. * @param node defines where to store the animation ranges
  33285. * @param parsedNode defines the serialization object to read data from
  33286. * @param scene defines the hosting scene
  33287. */
  33288. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33289. /**
  33290. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33291. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33292. * @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
  33293. * @returns the new bounding vectors
  33294. */
  33295. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33296. min: Vector3;
  33297. max: Vector3;
  33298. };
  33299. }
  33300. }
  33301. declare module BABYLON {
  33302. /**
  33303. * @hidden
  33304. */
  33305. export class _IAnimationState {
  33306. key: number;
  33307. repeatCount: number;
  33308. workValue?: any;
  33309. loopMode?: number;
  33310. offsetValue?: any;
  33311. highLimitValue?: any;
  33312. }
  33313. /**
  33314. * Class used to store any kind of animation
  33315. */
  33316. export class Animation {
  33317. /**Name of the animation */
  33318. name: string;
  33319. /**Property to animate */
  33320. targetProperty: string;
  33321. /**The frames per second of the animation */
  33322. framePerSecond: number;
  33323. /**The data type of the animation */
  33324. dataType: number;
  33325. /**The loop mode of the animation */
  33326. loopMode?: number | undefined;
  33327. /**Specifies if blending should be enabled */
  33328. enableBlending?: boolean | undefined;
  33329. /**
  33330. * Use matrix interpolation instead of using direct key value when animating matrices
  33331. */
  33332. static AllowMatricesInterpolation: boolean;
  33333. /**
  33334. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33335. */
  33336. static AllowMatrixDecomposeForInterpolation: boolean;
  33337. /** Define the Url to load snippets */
  33338. static SnippetUrl: string;
  33339. /** Snippet ID if the animation was created from the snippet server */
  33340. snippetId: string;
  33341. /**
  33342. * Stores the key frames of the animation
  33343. */
  33344. private _keys;
  33345. /**
  33346. * Stores the easing function of the animation
  33347. */
  33348. private _easingFunction;
  33349. /**
  33350. * @hidden Internal use only
  33351. */
  33352. _runtimeAnimations: RuntimeAnimation[];
  33353. /**
  33354. * The set of event that will be linked to this animation
  33355. */
  33356. private _events;
  33357. /**
  33358. * Stores an array of target property paths
  33359. */
  33360. targetPropertyPath: string[];
  33361. /**
  33362. * Stores the blending speed of the animation
  33363. */
  33364. blendingSpeed: number;
  33365. /**
  33366. * Stores the animation ranges for the animation
  33367. */
  33368. private _ranges;
  33369. /**
  33370. * @hidden Internal use
  33371. */
  33372. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33373. /**
  33374. * Sets up an animation
  33375. * @param property The property to animate
  33376. * @param animationType The animation type to apply
  33377. * @param framePerSecond The frames per second of the animation
  33378. * @param easingFunction The easing function used in the animation
  33379. * @returns The created animation
  33380. */
  33381. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33382. /**
  33383. * Create and start an animation on a node
  33384. * @param name defines the name of the global animation that will be run on all nodes
  33385. * @param node defines the root node where the animation will take place
  33386. * @param targetProperty defines property to animate
  33387. * @param framePerSecond defines the number of frame per second yo use
  33388. * @param totalFrame defines the number of frames in total
  33389. * @param from defines the initial value
  33390. * @param to defines the final value
  33391. * @param loopMode defines which loop mode you want to use (off by default)
  33392. * @param easingFunction defines the easing function to use (linear by default)
  33393. * @param onAnimationEnd defines the callback to call when animation end
  33394. * @returns the animatable created for this animation
  33395. */
  33396. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33397. /**
  33398. * Create and start an animation on a node and its descendants
  33399. * @param name defines the name of the global animation that will be run on all nodes
  33400. * @param node defines the root node where the animation will take place
  33401. * @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
  33402. * @param targetProperty defines property to animate
  33403. * @param framePerSecond defines the number of frame per second to use
  33404. * @param totalFrame defines the number of frames in total
  33405. * @param from defines the initial value
  33406. * @param to defines the final value
  33407. * @param loopMode defines which loop mode you want to use (off by default)
  33408. * @param easingFunction defines the easing function to use (linear by default)
  33409. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33410. * @returns the list of animatables created for all nodes
  33411. * @example https://www.babylonjs-playground.com/#MH0VLI
  33412. */
  33413. 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[]>;
  33414. /**
  33415. * Creates a new animation, merges it with the existing animations and starts it
  33416. * @param name Name of the animation
  33417. * @param node Node which contains the scene that begins the animations
  33418. * @param targetProperty Specifies which property to animate
  33419. * @param framePerSecond The frames per second of the animation
  33420. * @param totalFrame The total number of frames
  33421. * @param from The frame at the beginning of the animation
  33422. * @param to The frame at the end of the animation
  33423. * @param loopMode Specifies the loop mode of the animation
  33424. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33425. * @param onAnimationEnd Callback to run once the animation is complete
  33426. * @returns Nullable animation
  33427. */
  33428. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33429. /**
  33430. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33431. * @param sourceAnimation defines the Animation containing keyframes to convert
  33432. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33433. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33434. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33435. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33436. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33437. */
  33438. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33439. /**
  33440. * Transition property of an host to the target Value
  33441. * @param property The property to transition
  33442. * @param targetValue The target Value of the property
  33443. * @param host The object where the property to animate belongs
  33444. * @param scene Scene used to run the animation
  33445. * @param frameRate Framerate (in frame/s) to use
  33446. * @param transition The transition type we want to use
  33447. * @param duration The duration of the animation, in milliseconds
  33448. * @param onAnimationEnd Callback trigger at the end of the animation
  33449. * @returns Nullable animation
  33450. */
  33451. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33452. /**
  33453. * Return the array of runtime animations currently using this animation
  33454. */
  33455. get runtimeAnimations(): RuntimeAnimation[];
  33456. /**
  33457. * Specifies if any of the runtime animations are currently running
  33458. */
  33459. get hasRunningRuntimeAnimations(): boolean;
  33460. /**
  33461. * Initializes the animation
  33462. * @param name Name of the animation
  33463. * @param targetProperty Property to animate
  33464. * @param framePerSecond The frames per second of the animation
  33465. * @param dataType The data type of the animation
  33466. * @param loopMode The loop mode of the animation
  33467. * @param enableBlending Specifies if blending should be enabled
  33468. */
  33469. constructor(
  33470. /**Name of the animation */
  33471. name: string,
  33472. /**Property to animate */
  33473. targetProperty: string,
  33474. /**The frames per second of the animation */
  33475. framePerSecond: number,
  33476. /**The data type of the animation */
  33477. dataType: number,
  33478. /**The loop mode of the animation */
  33479. loopMode?: number | undefined,
  33480. /**Specifies if blending should be enabled */
  33481. enableBlending?: boolean | undefined);
  33482. /**
  33483. * Converts the animation to a string
  33484. * @param fullDetails support for multiple levels of logging within scene loading
  33485. * @returns String form of the animation
  33486. */
  33487. toString(fullDetails?: boolean): string;
  33488. /**
  33489. * Add an event to this animation
  33490. * @param event Event to add
  33491. */
  33492. addEvent(event: AnimationEvent): void;
  33493. /**
  33494. * Remove all events found at the given frame
  33495. * @param frame The frame to remove events from
  33496. */
  33497. removeEvents(frame: number): void;
  33498. /**
  33499. * Retrieves all the events from the animation
  33500. * @returns Events from the animation
  33501. */
  33502. getEvents(): AnimationEvent[];
  33503. /**
  33504. * Creates an animation range
  33505. * @param name Name of the animation range
  33506. * @param from Starting frame of the animation range
  33507. * @param to Ending frame of the animation
  33508. */
  33509. createRange(name: string, from: number, to: number): void;
  33510. /**
  33511. * Deletes an animation range by name
  33512. * @param name Name of the animation range to delete
  33513. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33514. */
  33515. deleteRange(name: string, deleteFrames?: boolean): void;
  33516. /**
  33517. * Gets the animation range by name, or null if not defined
  33518. * @param name Name of the animation range
  33519. * @returns Nullable animation range
  33520. */
  33521. getRange(name: string): Nullable<AnimationRange>;
  33522. /**
  33523. * Gets the key frames from the animation
  33524. * @returns The key frames of the animation
  33525. */
  33526. getKeys(): Array<IAnimationKey>;
  33527. /**
  33528. * Gets the highest frame rate of the animation
  33529. * @returns Highest frame rate of the animation
  33530. */
  33531. getHighestFrame(): number;
  33532. /**
  33533. * Gets the easing function of the animation
  33534. * @returns Easing function of the animation
  33535. */
  33536. getEasingFunction(): IEasingFunction;
  33537. /**
  33538. * Sets the easing function of the animation
  33539. * @param easingFunction A custom mathematical formula for animation
  33540. */
  33541. setEasingFunction(easingFunction: EasingFunction): void;
  33542. /**
  33543. * Interpolates a scalar linearly
  33544. * @param startValue Start value of the animation curve
  33545. * @param endValue End value of the animation curve
  33546. * @param gradient Scalar amount to interpolate
  33547. * @returns Interpolated scalar value
  33548. */
  33549. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33550. /**
  33551. * Interpolates a scalar cubically
  33552. * @param startValue Start value of the animation curve
  33553. * @param outTangent End tangent of the animation
  33554. * @param endValue End value of the animation curve
  33555. * @param inTangent Start tangent of the animation curve
  33556. * @param gradient Scalar amount to interpolate
  33557. * @returns Interpolated scalar value
  33558. */
  33559. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33560. /**
  33561. * Interpolates a quaternion using a spherical linear interpolation
  33562. * @param startValue Start value of the animation curve
  33563. * @param endValue End value of the animation curve
  33564. * @param gradient Scalar amount to interpolate
  33565. * @returns Interpolated quaternion value
  33566. */
  33567. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33568. /**
  33569. * Interpolates a quaternion cubically
  33570. * @param startValue Start value of the animation curve
  33571. * @param outTangent End tangent of the animation curve
  33572. * @param endValue End value of the animation curve
  33573. * @param inTangent Start tangent of the animation curve
  33574. * @param gradient Scalar amount to interpolate
  33575. * @returns Interpolated quaternion value
  33576. */
  33577. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33578. /**
  33579. * Interpolates a Vector3 linearl
  33580. * @param startValue Start value of the animation curve
  33581. * @param endValue End value of the animation curve
  33582. * @param gradient Scalar amount to interpolate
  33583. * @returns Interpolated scalar value
  33584. */
  33585. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33586. /**
  33587. * Interpolates a Vector3 cubically
  33588. * @param startValue Start value of the animation curve
  33589. * @param outTangent End tangent of the animation
  33590. * @param endValue End value of the animation curve
  33591. * @param inTangent Start tangent of the animation curve
  33592. * @param gradient Scalar amount to interpolate
  33593. * @returns InterpolatedVector3 value
  33594. */
  33595. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33596. /**
  33597. * Interpolates a Vector2 linearly
  33598. * @param startValue Start value of the animation curve
  33599. * @param endValue End value of the animation curve
  33600. * @param gradient Scalar amount to interpolate
  33601. * @returns Interpolated Vector2 value
  33602. */
  33603. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33604. /**
  33605. * Interpolates a Vector2 cubically
  33606. * @param startValue Start value of the animation curve
  33607. * @param outTangent End tangent of the animation
  33608. * @param endValue End value of the animation curve
  33609. * @param inTangent Start tangent of the animation curve
  33610. * @param gradient Scalar amount to interpolate
  33611. * @returns Interpolated Vector2 value
  33612. */
  33613. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33614. /**
  33615. * Interpolates a size linearly
  33616. * @param startValue Start value of the animation curve
  33617. * @param endValue End value of the animation curve
  33618. * @param gradient Scalar amount to interpolate
  33619. * @returns Interpolated Size value
  33620. */
  33621. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33622. /**
  33623. * Interpolates a Color3 linearly
  33624. * @param startValue Start value of the animation curve
  33625. * @param endValue End value of the animation curve
  33626. * @param gradient Scalar amount to interpolate
  33627. * @returns Interpolated Color3 value
  33628. */
  33629. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33630. /**
  33631. * Interpolates a Color4 linearly
  33632. * @param startValue Start value of the animation curve
  33633. * @param endValue End value of the animation curve
  33634. * @param gradient Scalar amount to interpolate
  33635. * @returns Interpolated Color3 value
  33636. */
  33637. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33638. /**
  33639. * @hidden Internal use only
  33640. */
  33641. _getKeyValue(value: any): any;
  33642. /**
  33643. * @hidden Internal use only
  33644. */
  33645. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33646. /**
  33647. * Defines the function to use to interpolate matrices
  33648. * @param startValue defines the start matrix
  33649. * @param endValue defines the end matrix
  33650. * @param gradient defines the gradient between both matrices
  33651. * @param result defines an optional target matrix where to store the interpolation
  33652. * @returns the interpolated matrix
  33653. */
  33654. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33655. /**
  33656. * Makes a copy of the animation
  33657. * @returns Cloned animation
  33658. */
  33659. clone(): Animation;
  33660. /**
  33661. * Sets the key frames of the animation
  33662. * @param values The animation key frames to set
  33663. */
  33664. setKeys(values: Array<IAnimationKey>): void;
  33665. /**
  33666. * Serializes the animation to an object
  33667. * @returns Serialized object
  33668. */
  33669. serialize(): any;
  33670. /**
  33671. * Float animation type
  33672. */
  33673. static readonly ANIMATIONTYPE_FLOAT: number;
  33674. /**
  33675. * Vector3 animation type
  33676. */
  33677. static readonly ANIMATIONTYPE_VECTOR3: number;
  33678. /**
  33679. * Quaternion animation type
  33680. */
  33681. static readonly ANIMATIONTYPE_QUATERNION: number;
  33682. /**
  33683. * Matrix animation type
  33684. */
  33685. static readonly ANIMATIONTYPE_MATRIX: number;
  33686. /**
  33687. * Color3 animation type
  33688. */
  33689. static readonly ANIMATIONTYPE_COLOR3: number;
  33690. /**
  33691. * Color3 animation type
  33692. */
  33693. static readonly ANIMATIONTYPE_COLOR4: number;
  33694. /**
  33695. * Vector2 animation type
  33696. */
  33697. static readonly ANIMATIONTYPE_VECTOR2: number;
  33698. /**
  33699. * Size animation type
  33700. */
  33701. static readonly ANIMATIONTYPE_SIZE: number;
  33702. /**
  33703. * Relative Loop Mode
  33704. */
  33705. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33706. /**
  33707. * Cycle Loop Mode
  33708. */
  33709. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33710. /**
  33711. * Constant Loop Mode
  33712. */
  33713. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33714. /** @hidden */
  33715. static _UniversalLerp(left: any, right: any, amount: number): any;
  33716. /**
  33717. * Parses an animation object and creates an animation
  33718. * @param parsedAnimation Parsed animation object
  33719. * @returns Animation object
  33720. */
  33721. static Parse(parsedAnimation: any): Animation;
  33722. /**
  33723. * Appends the serialized animations from the source animations
  33724. * @param source Source containing the animations
  33725. * @param destination Target to store the animations
  33726. */
  33727. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33728. /**
  33729. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33730. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33731. * @param url defines the url to load from
  33732. * @returns a promise that will resolve to the new animation or an array of animations
  33733. */
  33734. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33735. /**
  33736. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33737. * @param snippetId defines the snippet to load
  33738. * @returns a promise that will resolve to the new animation or a new array of animations
  33739. */
  33740. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33741. }
  33742. }
  33743. declare module BABYLON {
  33744. /**
  33745. * Interface containing an array of animations
  33746. */
  33747. export interface IAnimatable {
  33748. /**
  33749. * Array of animations
  33750. */
  33751. animations: Nullable<Array<Animation>>;
  33752. }
  33753. }
  33754. declare module BABYLON {
  33755. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33756. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33757. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33758. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33759. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33760. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33761. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33762. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33763. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33764. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33765. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33766. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33767. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33768. /**
  33769. * Decorator used to define property that can be serialized as reference to a camera
  33770. * @param sourceName defines the name of the property to decorate
  33771. */
  33772. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33773. /**
  33774. * Class used to help serialization objects
  33775. */
  33776. export class SerializationHelper {
  33777. /** @hidden */
  33778. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33779. /** @hidden */
  33780. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33781. /** @hidden */
  33782. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33783. /** @hidden */
  33784. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33785. /**
  33786. * Appends the serialized animations from the source animations
  33787. * @param source Source containing the animations
  33788. * @param destination Target to store the animations
  33789. */
  33790. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33791. /**
  33792. * Static function used to serialized a specific entity
  33793. * @param entity defines the entity to serialize
  33794. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33795. * @returns a JSON compatible object representing the serialization of the entity
  33796. */
  33797. static Serialize<T>(entity: T, serializationObject?: any): any;
  33798. /**
  33799. * Creates a new entity from a serialization data object
  33800. * @param creationFunction defines a function used to instanciated the new entity
  33801. * @param source defines the source serialization data
  33802. * @param scene defines the hosting scene
  33803. * @param rootUrl defines the root url for resources
  33804. * @returns a new entity
  33805. */
  33806. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33807. /**
  33808. * Clones an object
  33809. * @param creationFunction defines the function used to instanciate the new object
  33810. * @param source defines the source object
  33811. * @returns the cloned object
  33812. */
  33813. static Clone<T>(creationFunction: () => T, source: T): T;
  33814. /**
  33815. * Instanciates a new object based on a source one (some data will be shared between both object)
  33816. * @param creationFunction defines the function used to instanciate the new object
  33817. * @param source defines the source object
  33818. * @returns the new object
  33819. */
  33820. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33821. }
  33822. }
  33823. declare module BABYLON {
  33824. /**
  33825. * Base class of all the textures in babylon.
  33826. * It groups all the common properties the materials, post process, lights... might need
  33827. * in order to make a correct use of the texture.
  33828. */
  33829. export class BaseTexture implements IAnimatable {
  33830. /**
  33831. * Default anisotropic filtering level for the application.
  33832. * It is set to 4 as a good tradeoff between perf and quality.
  33833. */
  33834. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33835. /**
  33836. * Gets or sets the unique id of the texture
  33837. */
  33838. uniqueId: number;
  33839. /**
  33840. * Define the name of the texture.
  33841. */
  33842. name: string;
  33843. /**
  33844. * Gets or sets an object used to store user defined information.
  33845. */
  33846. metadata: any;
  33847. /**
  33848. * For internal use only. Please do not use.
  33849. */
  33850. reservedDataStore: any;
  33851. private _hasAlpha;
  33852. /**
  33853. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33854. */
  33855. set hasAlpha(value: boolean);
  33856. get hasAlpha(): boolean;
  33857. /**
  33858. * Defines if the alpha value should be determined via the rgb values.
  33859. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33860. */
  33861. getAlphaFromRGB: boolean;
  33862. /**
  33863. * Intensity or strength of the texture.
  33864. * It is commonly used by materials to fine tune the intensity of the texture
  33865. */
  33866. level: number;
  33867. /**
  33868. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33869. * This is part of the texture as textures usually maps to one uv set.
  33870. */
  33871. coordinatesIndex: number;
  33872. protected _coordinatesMode: number;
  33873. /**
  33874. * How a texture is mapped.
  33875. *
  33876. * | Value | Type | Description |
  33877. * | ----- | ----------------------------------- | ----------- |
  33878. * | 0 | EXPLICIT_MODE | |
  33879. * | 1 | SPHERICAL_MODE | |
  33880. * | 2 | PLANAR_MODE | |
  33881. * | 3 | CUBIC_MODE | |
  33882. * | 4 | PROJECTION_MODE | |
  33883. * | 5 | SKYBOX_MODE | |
  33884. * | 6 | INVCUBIC_MODE | |
  33885. * | 7 | EQUIRECTANGULAR_MODE | |
  33886. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33887. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33888. */
  33889. set coordinatesMode(value: number);
  33890. get coordinatesMode(): number;
  33891. private _wrapU;
  33892. /**
  33893. * | Value | Type | Description |
  33894. * | ----- | ------------------ | ----------- |
  33895. * | 0 | CLAMP_ADDRESSMODE | |
  33896. * | 1 | WRAP_ADDRESSMODE | |
  33897. * | 2 | MIRROR_ADDRESSMODE | |
  33898. */
  33899. get wrapU(): number;
  33900. set wrapU(value: number);
  33901. private _wrapV;
  33902. /**
  33903. * | Value | Type | Description |
  33904. * | ----- | ------------------ | ----------- |
  33905. * | 0 | CLAMP_ADDRESSMODE | |
  33906. * | 1 | WRAP_ADDRESSMODE | |
  33907. * | 2 | MIRROR_ADDRESSMODE | |
  33908. */
  33909. get wrapV(): number;
  33910. set wrapV(value: number);
  33911. /**
  33912. * | Value | Type | Description |
  33913. * | ----- | ------------------ | ----------- |
  33914. * | 0 | CLAMP_ADDRESSMODE | |
  33915. * | 1 | WRAP_ADDRESSMODE | |
  33916. * | 2 | MIRROR_ADDRESSMODE | |
  33917. */
  33918. wrapR: number;
  33919. /**
  33920. * With compliant hardware and browser (supporting anisotropic filtering)
  33921. * this defines the level of anisotropic filtering in the texture.
  33922. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33923. */
  33924. anisotropicFilteringLevel: number;
  33925. /**
  33926. * Define if the texture is a cube texture or if false a 2d texture.
  33927. */
  33928. get isCube(): boolean;
  33929. set isCube(value: boolean);
  33930. /**
  33931. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33932. */
  33933. get is3D(): boolean;
  33934. set is3D(value: boolean);
  33935. /**
  33936. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33937. */
  33938. get is2DArray(): boolean;
  33939. set is2DArray(value: boolean);
  33940. private _gammaSpace;
  33941. /**
  33942. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33943. * HDR texture are usually stored in linear space.
  33944. * This only impacts the PBR and Background materials
  33945. */
  33946. get gammaSpace(): boolean;
  33947. set gammaSpace(gamma: boolean);
  33948. /**
  33949. * Gets or sets whether or not the texture contains RGBD data.
  33950. */
  33951. get isRGBD(): boolean;
  33952. set isRGBD(value: boolean);
  33953. /**
  33954. * Is Z inverted in the texture (useful in a cube texture).
  33955. */
  33956. invertZ: boolean;
  33957. /**
  33958. * Are mip maps generated for this texture or not.
  33959. */
  33960. get noMipmap(): boolean;
  33961. /**
  33962. * @hidden
  33963. */
  33964. lodLevelInAlpha: boolean;
  33965. /**
  33966. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33967. */
  33968. get lodGenerationOffset(): number;
  33969. set lodGenerationOffset(value: number);
  33970. /**
  33971. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33972. */
  33973. get lodGenerationScale(): number;
  33974. set lodGenerationScale(value: number);
  33975. /**
  33976. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33977. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33978. * average roughness values.
  33979. */
  33980. get linearSpecularLOD(): boolean;
  33981. set linearSpecularLOD(value: boolean);
  33982. /**
  33983. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33984. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33985. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33986. */
  33987. get irradianceTexture(): Nullable<BaseTexture>;
  33988. set irradianceTexture(value: Nullable<BaseTexture>);
  33989. /**
  33990. * Define if the texture is a render target.
  33991. */
  33992. isRenderTarget: boolean;
  33993. /**
  33994. * Define the unique id of the texture in the scene.
  33995. */
  33996. get uid(): string;
  33997. /** @hidden */
  33998. _prefiltered: boolean;
  33999. /**
  34000. * Return a string representation of the texture.
  34001. * @returns the texture as a string
  34002. */
  34003. toString(): string;
  34004. /**
  34005. * Get the class name of the texture.
  34006. * @returns "BaseTexture"
  34007. */
  34008. getClassName(): string;
  34009. /**
  34010. * Define the list of animation attached to the texture.
  34011. */
  34012. animations: Animation[];
  34013. /**
  34014. * An event triggered when the texture is disposed.
  34015. */
  34016. onDisposeObservable: Observable<BaseTexture>;
  34017. private _onDisposeObserver;
  34018. /**
  34019. * Callback triggered when the texture has been disposed.
  34020. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34021. */
  34022. set onDispose(callback: () => void);
  34023. /**
  34024. * Define the current state of the loading sequence when in delayed load mode.
  34025. */
  34026. delayLoadState: number;
  34027. protected _scene: Nullable<Scene>;
  34028. protected _engine: Nullable<ThinEngine>;
  34029. /** @hidden */
  34030. _texture: Nullable<InternalTexture>;
  34031. private _uid;
  34032. /**
  34033. * Define if the texture is preventinga material to render or not.
  34034. * If not and the texture is not ready, the engine will use a default black texture instead.
  34035. */
  34036. get isBlocking(): boolean;
  34037. /**
  34038. * Instantiates a new BaseTexture.
  34039. * Base class of all the textures in babylon.
  34040. * It groups all the common properties the materials, post process, lights... might need
  34041. * in order to make a correct use of the texture.
  34042. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34043. */
  34044. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34045. /**
  34046. * Get the scene the texture belongs to.
  34047. * @returns the scene or null if undefined
  34048. */
  34049. getScene(): Nullable<Scene>;
  34050. /** @hidden */
  34051. protected _getEngine(): Nullable<ThinEngine>;
  34052. /**
  34053. * Get the texture transform matrix used to offset tile the texture for istance.
  34054. * @returns the transformation matrix
  34055. */
  34056. getTextureMatrix(): Matrix;
  34057. /**
  34058. * Get the texture reflection matrix used to rotate/transform the reflection.
  34059. * @returns the reflection matrix
  34060. */
  34061. getReflectionTextureMatrix(): Matrix;
  34062. /**
  34063. * Get the underlying lower level texture from Babylon.
  34064. * @returns the insternal texture
  34065. */
  34066. getInternalTexture(): Nullable<InternalTexture>;
  34067. /**
  34068. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34069. * @returns true if ready or not blocking
  34070. */
  34071. isReadyOrNotBlocking(): boolean;
  34072. /**
  34073. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34074. * @returns true if fully ready
  34075. */
  34076. isReady(): boolean;
  34077. private _cachedSize;
  34078. /**
  34079. * Get the size of the texture.
  34080. * @returns the texture size.
  34081. */
  34082. getSize(): ISize;
  34083. /**
  34084. * Get the base size of the texture.
  34085. * It can be different from the size if the texture has been resized for POT for instance
  34086. * @returns the base size
  34087. */
  34088. getBaseSize(): ISize;
  34089. /**
  34090. * Update the sampling mode of the texture.
  34091. * Default is Trilinear mode.
  34092. *
  34093. * | Value | Type | Description |
  34094. * | ----- | ------------------ | ----------- |
  34095. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34096. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34097. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34098. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34099. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34100. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34101. * | 7 | NEAREST_LINEAR | |
  34102. * | 8 | NEAREST_NEAREST | |
  34103. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34104. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34105. * | 11 | LINEAR_LINEAR | |
  34106. * | 12 | LINEAR_NEAREST | |
  34107. *
  34108. * > _mag_: magnification filter (close to the viewer)
  34109. * > _min_: minification filter (far from the viewer)
  34110. * > _mip_: filter used between mip map levels
  34111. *@param samplingMode Define the new sampling mode of the texture
  34112. */
  34113. updateSamplingMode(samplingMode: number): void;
  34114. /**
  34115. * Scales the texture if is `canRescale()`
  34116. * @param ratio the resize factor we want to use to rescale
  34117. */
  34118. scale(ratio: number): void;
  34119. /**
  34120. * Get if the texture can rescale.
  34121. */
  34122. get canRescale(): boolean;
  34123. /** @hidden */
  34124. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34125. /** @hidden */
  34126. _rebuild(): void;
  34127. /**
  34128. * Triggers the load sequence in delayed load mode.
  34129. */
  34130. delayLoad(): void;
  34131. /**
  34132. * Clones the texture.
  34133. * @returns the cloned texture
  34134. */
  34135. clone(): Nullable<BaseTexture>;
  34136. /**
  34137. * Get the texture underlying type (INT, FLOAT...)
  34138. */
  34139. get textureType(): number;
  34140. /**
  34141. * Get the texture underlying format (RGB, RGBA...)
  34142. */
  34143. get textureFormat(): number;
  34144. /**
  34145. * Indicates that textures need to be re-calculated for all materials
  34146. */
  34147. protected _markAllSubMeshesAsTexturesDirty(): void;
  34148. /**
  34149. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34150. * This will returns an RGBA array buffer containing either in values (0-255) or
  34151. * float values (0-1) depending of the underlying buffer type.
  34152. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34153. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34154. * @param buffer defines a user defined buffer to fill with data (can be null)
  34155. * @returns The Array buffer containing the pixels data.
  34156. */
  34157. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34158. /**
  34159. * Release and destroy the underlying lower level texture aka internalTexture.
  34160. */
  34161. releaseInternalTexture(): void;
  34162. /** @hidden */
  34163. get _lodTextureHigh(): Nullable<BaseTexture>;
  34164. /** @hidden */
  34165. get _lodTextureMid(): Nullable<BaseTexture>;
  34166. /** @hidden */
  34167. get _lodTextureLow(): Nullable<BaseTexture>;
  34168. /**
  34169. * Dispose the texture and release its associated resources.
  34170. */
  34171. dispose(): void;
  34172. /**
  34173. * Serialize the texture into a JSON representation that can be parsed later on.
  34174. * @returns the JSON representation of the texture
  34175. */
  34176. serialize(): any;
  34177. /**
  34178. * Helper function to be called back once a list of texture contains only ready textures.
  34179. * @param textures Define the list of textures to wait for
  34180. * @param callback Define the callback triggered once the entire list will be ready
  34181. */
  34182. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34183. private static _isScene;
  34184. }
  34185. }
  34186. declare module BABYLON {
  34187. /**
  34188. * Options to be used when creating an effect.
  34189. */
  34190. export interface IEffectCreationOptions {
  34191. /**
  34192. * Atrributes that will be used in the shader.
  34193. */
  34194. attributes: string[];
  34195. /**
  34196. * Uniform varible names that will be set in the shader.
  34197. */
  34198. uniformsNames: string[];
  34199. /**
  34200. * Uniform buffer variable names that will be set in the shader.
  34201. */
  34202. uniformBuffersNames: string[];
  34203. /**
  34204. * Sampler texture variable names that will be set in the shader.
  34205. */
  34206. samplers: string[];
  34207. /**
  34208. * Define statements that will be set in the shader.
  34209. */
  34210. defines: any;
  34211. /**
  34212. * Possible fallbacks for this effect to improve performance when needed.
  34213. */
  34214. fallbacks: Nullable<IEffectFallbacks>;
  34215. /**
  34216. * Callback that will be called when the shader is compiled.
  34217. */
  34218. onCompiled: Nullable<(effect: Effect) => void>;
  34219. /**
  34220. * Callback that will be called if an error occurs during shader compilation.
  34221. */
  34222. onError: Nullable<(effect: Effect, errors: string) => void>;
  34223. /**
  34224. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34225. */
  34226. indexParameters?: any;
  34227. /**
  34228. * Max number of lights that can be used in the shader.
  34229. */
  34230. maxSimultaneousLights?: number;
  34231. /**
  34232. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34233. */
  34234. transformFeedbackVaryings?: Nullable<string[]>;
  34235. /**
  34236. * 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
  34237. */
  34238. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34239. /**
  34240. * Is this effect rendering to several color attachments ?
  34241. */
  34242. multiTarget?: boolean;
  34243. }
  34244. /**
  34245. * Effect containing vertex and fragment shader that can be executed on an object.
  34246. */
  34247. export class Effect implements IDisposable {
  34248. /**
  34249. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34250. */
  34251. static ShadersRepository: string;
  34252. /**
  34253. * Enable logging of the shader code when a compilation error occurs
  34254. */
  34255. static LogShaderCodeOnCompilationError: boolean;
  34256. /**
  34257. * Name of the effect.
  34258. */
  34259. name: any;
  34260. /**
  34261. * String container all the define statements that should be set on the shader.
  34262. */
  34263. defines: string;
  34264. /**
  34265. * Callback that will be called when the shader is compiled.
  34266. */
  34267. onCompiled: Nullable<(effect: Effect) => void>;
  34268. /**
  34269. * Callback that will be called if an error occurs during shader compilation.
  34270. */
  34271. onError: Nullable<(effect: Effect, errors: string) => void>;
  34272. /**
  34273. * Callback that will be called when effect is bound.
  34274. */
  34275. onBind: Nullable<(effect: Effect) => void>;
  34276. /**
  34277. * Unique ID of the effect.
  34278. */
  34279. uniqueId: number;
  34280. /**
  34281. * Observable that will be called when the shader is compiled.
  34282. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34283. */
  34284. onCompileObservable: Observable<Effect>;
  34285. /**
  34286. * Observable that will be called if an error occurs during shader compilation.
  34287. */
  34288. onErrorObservable: Observable<Effect>;
  34289. /** @hidden */
  34290. _onBindObservable: Nullable<Observable<Effect>>;
  34291. /**
  34292. * @hidden
  34293. * Specifies if the effect was previously ready
  34294. */
  34295. _wasPreviouslyReady: boolean;
  34296. /**
  34297. * Observable that will be called when effect is bound.
  34298. */
  34299. get onBindObservable(): Observable<Effect>;
  34300. /** @hidden */
  34301. _bonesComputationForcedToCPU: boolean;
  34302. /** @hidden */
  34303. _multiTarget: boolean;
  34304. private static _uniqueIdSeed;
  34305. private _engine;
  34306. private _uniformBuffersNames;
  34307. private _uniformBuffersNamesList;
  34308. private _uniformsNames;
  34309. private _samplerList;
  34310. private _samplers;
  34311. private _isReady;
  34312. private _compilationError;
  34313. private _allFallbacksProcessed;
  34314. private _attributesNames;
  34315. private _attributes;
  34316. private _attributeLocationByName;
  34317. private _uniforms;
  34318. /**
  34319. * Key for the effect.
  34320. * @hidden
  34321. */
  34322. _key: string;
  34323. private _indexParameters;
  34324. private _fallbacks;
  34325. private _vertexSourceCode;
  34326. private _fragmentSourceCode;
  34327. private _vertexSourceCodeOverride;
  34328. private _fragmentSourceCodeOverride;
  34329. private _transformFeedbackVaryings;
  34330. /**
  34331. * Compiled shader to webGL program.
  34332. * @hidden
  34333. */
  34334. _pipelineContext: Nullable<IPipelineContext>;
  34335. private _valueCache;
  34336. private static _baseCache;
  34337. /**
  34338. * Instantiates an effect.
  34339. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34340. * @param baseName Name of the effect.
  34341. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34342. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34343. * @param samplers List of sampler variables that will be passed to the shader.
  34344. * @param engine Engine to be used to render the effect
  34345. * @param defines Define statements to be added to the shader.
  34346. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34347. * @param onCompiled Callback that will be called when the shader is compiled.
  34348. * @param onError Callback that will be called if an error occurs during shader compilation.
  34349. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34350. */
  34351. 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);
  34352. private _useFinalCode;
  34353. /**
  34354. * Unique key for this effect
  34355. */
  34356. get key(): string;
  34357. /**
  34358. * If the effect has been compiled and prepared.
  34359. * @returns if the effect is compiled and prepared.
  34360. */
  34361. isReady(): boolean;
  34362. private _isReadyInternal;
  34363. /**
  34364. * The engine the effect was initialized with.
  34365. * @returns the engine.
  34366. */
  34367. getEngine(): Engine;
  34368. /**
  34369. * The pipeline context for this effect
  34370. * @returns the associated pipeline context
  34371. */
  34372. getPipelineContext(): Nullable<IPipelineContext>;
  34373. /**
  34374. * The set of names of attribute variables for the shader.
  34375. * @returns An array of attribute names.
  34376. */
  34377. getAttributesNames(): string[];
  34378. /**
  34379. * Returns the attribute at the given index.
  34380. * @param index The index of the attribute.
  34381. * @returns The location of the attribute.
  34382. */
  34383. getAttributeLocation(index: number): number;
  34384. /**
  34385. * Returns the attribute based on the name of the variable.
  34386. * @param name of the attribute to look up.
  34387. * @returns the attribute location.
  34388. */
  34389. getAttributeLocationByName(name: string): number;
  34390. /**
  34391. * The number of attributes.
  34392. * @returns the numnber of attributes.
  34393. */
  34394. getAttributesCount(): number;
  34395. /**
  34396. * Gets the index of a uniform variable.
  34397. * @param uniformName of the uniform to look up.
  34398. * @returns the index.
  34399. */
  34400. getUniformIndex(uniformName: string): number;
  34401. /**
  34402. * Returns the attribute based on the name of the variable.
  34403. * @param uniformName of the uniform to look up.
  34404. * @returns the location of the uniform.
  34405. */
  34406. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34407. /**
  34408. * Returns an array of sampler variable names
  34409. * @returns The array of sampler variable names.
  34410. */
  34411. getSamplers(): string[];
  34412. /**
  34413. * Returns an array of uniform variable names
  34414. * @returns The array of uniform variable names.
  34415. */
  34416. getUniformNames(): string[];
  34417. /**
  34418. * Returns an array of uniform buffer variable names
  34419. * @returns The array of uniform buffer variable names.
  34420. */
  34421. getUniformBuffersNames(): string[];
  34422. /**
  34423. * Returns the index parameters used to create the effect
  34424. * @returns The index parameters object
  34425. */
  34426. getIndexParameters(): any;
  34427. /**
  34428. * The error from the last compilation.
  34429. * @returns the error string.
  34430. */
  34431. getCompilationError(): string;
  34432. /**
  34433. * Gets a boolean indicating that all fallbacks were used during compilation
  34434. * @returns true if all fallbacks were used
  34435. */
  34436. allFallbacksProcessed(): boolean;
  34437. /**
  34438. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34439. * @param func The callback to be used.
  34440. */
  34441. executeWhenCompiled(func: (effect: Effect) => void): void;
  34442. private _checkIsReady;
  34443. private _loadShader;
  34444. /**
  34445. * Gets the vertex shader source code of this effect
  34446. */
  34447. get vertexSourceCode(): string;
  34448. /**
  34449. * Gets the fragment shader source code of this effect
  34450. */
  34451. get fragmentSourceCode(): string;
  34452. /**
  34453. * Recompiles the webGL program
  34454. * @param vertexSourceCode The source code for the vertex shader.
  34455. * @param fragmentSourceCode The source code for the fragment shader.
  34456. * @param onCompiled Callback called when completed.
  34457. * @param onError Callback called on error.
  34458. * @hidden
  34459. */
  34460. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34461. /**
  34462. * Prepares the effect
  34463. * @hidden
  34464. */
  34465. _prepareEffect(): void;
  34466. private _getShaderCodeAndErrorLine;
  34467. private _processCompilationErrors;
  34468. /**
  34469. * Checks if the effect is supported. (Must be called after compilation)
  34470. */
  34471. get isSupported(): boolean;
  34472. /**
  34473. * Binds a texture to the engine to be used as output of the shader.
  34474. * @param channel Name of the output variable.
  34475. * @param texture Texture to bind.
  34476. * @hidden
  34477. */
  34478. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34479. /**
  34480. * Sets a texture on the engine to be used in the shader.
  34481. * @param channel Name of the sampler variable.
  34482. * @param texture Texture to set.
  34483. */
  34484. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34485. /**
  34486. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34487. * @param channel Name of the sampler variable.
  34488. * @param texture Texture to set.
  34489. */
  34490. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34491. /**
  34492. * Sets an array of textures on the engine to be used in the shader.
  34493. * @param channel Name of the variable.
  34494. * @param textures Textures to set.
  34495. */
  34496. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34497. /**
  34498. * 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)
  34499. * @param channel Name of the sampler variable.
  34500. * @param postProcess Post process to get the input texture from.
  34501. */
  34502. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34503. /**
  34504. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34505. * 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)
  34506. * @param channel Name of the sampler variable.
  34507. * @param postProcess Post process to get the output texture from.
  34508. */
  34509. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34510. /** @hidden */
  34511. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34512. /** @hidden */
  34513. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34514. /** @hidden */
  34515. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34516. /** @hidden */
  34517. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34518. /**
  34519. * Binds a buffer to a uniform.
  34520. * @param buffer Buffer to bind.
  34521. * @param name Name of the uniform variable to bind to.
  34522. */
  34523. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34524. /**
  34525. * Binds block to a uniform.
  34526. * @param blockName Name of the block to bind.
  34527. * @param index Index to bind.
  34528. */
  34529. bindUniformBlock(blockName: string, index: number): void;
  34530. /**
  34531. * Sets an interger value on a uniform variable.
  34532. * @param uniformName Name of the variable.
  34533. * @param value Value to be set.
  34534. * @returns this effect.
  34535. */
  34536. setInt(uniformName: string, value: number): Effect;
  34537. /**
  34538. * Sets an int array on a uniform variable.
  34539. * @param uniformName Name of the variable.
  34540. * @param array array to be set.
  34541. * @returns this effect.
  34542. */
  34543. setIntArray(uniformName: string, array: Int32Array): Effect;
  34544. /**
  34545. * 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)
  34546. * @param uniformName Name of the variable.
  34547. * @param array array to be set.
  34548. * @returns this effect.
  34549. */
  34550. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34551. /**
  34552. * 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)
  34553. * @param uniformName Name of the variable.
  34554. * @param array array to be set.
  34555. * @returns this effect.
  34556. */
  34557. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34558. /**
  34559. * 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)
  34560. * @param uniformName Name of the variable.
  34561. * @param array array to be set.
  34562. * @returns this effect.
  34563. */
  34564. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34565. /**
  34566. * Sets an float array on a uniform variable.
  34567. * @param uniformName Name of the variable.
  34568. * @param array array to be set.
  34569. * @returns this effect.
  34570. */
  34571. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34572. /**
  34573. * 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)
  34574. * @param uniformName Name of the variable.
  34575. * @param array array to be set.
  34576. * @returns this effect.
  34577. */
  34578. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34579. /**
  34580. * 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)
  34581. * @param uniformName Name of the variable.
  34582. * @param array array to be set.
  34583. * @returns this effect.
  34584. */
  34585. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34586. /**
  34587. * 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)
  34588. * @param uniformName Name of the variable.
  34589. * @param array array to be set.
  34590. * @returns this effect.
  34591. */
  34592. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34593. /**
  34594. * Sets an array on a uniform variable.
  34595. * @param uniformName Name of the variable.
  34596. * @param array array to be set.
  34597. * @returns this effect.
  34598. */
  34599. setArray(uniformName: string, array: number[]): Effect;
  34600. /**
  34601. * 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)
  34602. * @param uniformName Name of the variable.
  34603. * @param array array to be set.
  34604. * @returns this effect.
  34605. */
  34606. setArray2(uniformName: string, array: number[]): Effect;
  34607. /**
  34608. * 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)
  34609. * @param uniformName Name of the variable.
  34610. * @param array array to be set.
  34611. * @returns this effect.
  34612. */
  34613. setArray3(uniformName: string, array: number[]): Effect;
  34614. /**
  34615. * 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)
  34616. * @param uniformName Name of the variable.
  34617. * @param array array to be set.
  34618. * @returns this effect.
  34619. */
  34620. setArray4(uniformName: string, array: number[]): Effect;
  34621. /**
  34622. * Sets matrices on a uniform variable.
  34623. * @param uniformName Name of the variable.
  34624. * @param matrices matrices to be set.
  34625. * @returns this effect.
  34626. */
  34627. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34628. /**
  34629. * Sets matrix on a uniform variable.
  34630. * @param uniformName Name of the variable.
  34631. * @param matrix matrix to be set.
  34632. * @returns this effect.
  34633. */
  34634. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34635. /**
  34636. * 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)
  34637. * @param uniformName Name of the variable.
  34638. * @param matrix matrix to be set.
  34639. * @returns this effect.
  34640. */
  34641. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34642. /**
  34643. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34644. * @param uniformName Name of the variable.
  34645. * @param matrix matrix to be set.
  34646. * @returns this effect.
  34647. */
  34648. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34649. /**
  34650. * Sets a float on a uniform variable.
  34651. * @param uniformName Name of the variable.
  34652. * @param value value to be set.
  34653. * @returns this effect.
  34654. */
  34655. setFloat(uniformName: string, value: number): Effect;
  34656. /**
  34657. * Sets a boolean on a uniform variable.
  34658. * @param uniformName Name of the variable.
  34659. * @param bool value to be set.
  34660. * @returns this effect.
  34661. */
  34662. setBool(uniformName: string, bool: boolean): Effect;
  34663. /**
  34664. * Sets a Vector2 on a uniform variable.
  34665. * @param uniformName Name of the variable.
  34666. * @param vector2 vector2 to be set.
  34667. * @returns this effect.
  34668. */
  34669. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34670. /**
  34671. * Sets a float2 on a uniform variable.
  34672. * @param uniformName Name of the variable.
  34673. * @param x First float in float2.
  34674. * @param y Second float in float2.
  34675. * @returns this effect.
  34676. */
  34677. setFloat2(uniformName: string, x: number, y: number): Effect;
  34678. /**
  34679. * Sets a Vector3 on a uniform variable.
  34680. * @param uniformName Name of the variable.
  34681. * @param vector3 Value to be set.
  34682. * @returns this effect.
  34683. */
  34684. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34685. /**
  34686. * Sets a float3 on a uniform variable.
  34687. * @param uniformName Name of the variable.
  34688. * @param x First float in float3.
  34689. * @param y Second float in float3.
  34690. * @param z Third float in float3.
  34691. * @returns this effect.
  34692. */
  34693. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34694. /**
  34695. * Sets a Vector4 on a uniform variable.
  34696. * @param uniformName Name of the variable.
  34697. * @param vector4 Value to be set.
  34698. * @returns this effect.
  34699. */
  34700. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34701. /**
  34702. * Sets a float4 on a uniform variable.
  34703. * @param uniformName Name of the variable.
  34704. * @param x First float in float4.
  34705. * @param y Second float in float4.
  34706. * @param z Third float in float4.
  34707. * @param w Fourth float in float4.
  34708. * @returns this effect.
  34709. */
  34710. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34711. /**
  34712. * Sets a Color3 on a uniform variable.
  34713. * @param uniformName Name of the variable.
  34714. * @param color3 Value to be set.
  34715. * @returns this effect.
  34716. */
  34717. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34718. /**
  34719. * Sets a Color4 on a uniform variable.
  34720. * @param uniformName Name of the variable.
  34721. * @param color3 Value to be set.
  34722. * @param alpha Alpha value to be set.
  34723. * @returns this effect.
  34724. */
  34725. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34726. /**
  34727. * Sets a Color4 on a uniform variable
  34728. * @param uniformName defines the name of the variable
  34729. * @param color4 defines the value to be set
  34730. * @returns this effect.
  34731. */
  34732. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34733. /** Release all associated resources */
  34734. dispose(): void;
  34735. /**
  34736. * This function will add a new shader to the shader store
  34737. * @param name the name of the shader
  34738. * @param pixelShader optional pixel shader content
  34739. * @param vertexShader optional vertex shader content
  34740. */
  34741. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34742. /**
  34743. * Store of each shader (The can be looked up using effect.key)
  34744. */
  34745. static ShadersStore: {
  34746. [key: string]: string;
  34747. };
  34748. /**
  34749. * Store of each included file for a shader (The can be looked up using effect.key)
  34750. */
  34751. static IncludesShadersStore: {
  34752. [key: string]: string;
  34753. };
  34754. /**
  34755. * Resets the cache of effects.
  34756. */
  34757. static ResetCache(): void;
  34758. }
  34759. }
  34760. declare module BABYLON {
  34761. /**
  34762. * Interface used to describe the capabilities of the engine relatively to the current browser
  34763. */
  34764. export interface EngineCapabilities {
  34765. /** Maximum textures units per fragment shader */
  34766. maxTexturesImageUnits: number;
  34767. /** Maximum texture units per vertex shader */
  34768. maxVertexTextureImageUnits: number;
  34769. /** Maximum textures units in the entire pipeline */
  34770. maxCombinedTexturesImageUnits: number;
  34771. /** Maximum texture size */
  34772. maxTextureSize: number;
  34773. /** Maximum texture samples */
  34774. maxSamples?: number;
  34775. /** Maximum cube texture size */
  34776. maxCubemapTextureSize: number;
  34777. /** Maximum render texture size */
  34778. maxRenderTextureSize: number;
  34779. /** Maximum number of vertex attributes */
  34780. maxVertexAttribs: number;
  34781. /** Maximum number of varyings */
  34782. maxVaryingVectors: number;
  34783. /** Maximum number of uniforms per vertex shader */
  34784. maxVertexUniformVectors: number;
  34785. /** Maximum number of uniforms per fragment shader */
  34786. maxFragmentUniformVectors: number;
  34787. /** Defines if standard derivates (dx/dy) are supported */
  34788. standardDerivatives: boolean;
  34789. /** Defines if s3tc texture compression is supported */
  34790. s3tc?: WEBGL_compressed_texture_s3tc;
  34791. /** Defines if pvrtc texture compression is supported */
  34792. pvrtc: any;
  34793. /** Defines if etc1 texture compression is supported */
  34794. etc1: any;
  34795. /** Defines if etc2 texture compression is supported */
  34796. etc2: any;
  34797. /** Defines if astc texture compression is supported */
  34798. astc: any;
  34799. /** Defines if bptc texture compression is supported */
  34800. bptc: any;
  34801. /** Defines if float textures are supported */
  34802. textureFloat: boolean;
  34803. /** Defines if vertex array objects are supported */
  34804. vertexArrayObject: boolean;
  34805. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34806. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34807. /** Gets the maximum level of anisotropy supported */
  34808. maxAnisotropy: number;
  34809. /** Defines if instancing is supported */
  34810. instancedArrays: boolean;
  34811. /** Defines if 32 bits indices are supported */
  34812. uintIndices: boolean;
  34813. /** Defines if high precision shaders are supported */
  34814. highPrecisionShaderSupported: boolean;
  34815. /** Defines if depth reading in the fragment shader is supported */
  34816. fragmentDepthSupported: boolean;
  34817. /** Defines if float texture linear filtering is supported*/
  34818. textureFloatLinearFiltering: boolean;
  34819. /** Defines if rendering to float textures is supported */
  34820. textureFloatRender: boolean;
  34821. /** Defines if half float textures are supported*/
  34822. textureHalfFloat: boolean;
  34823. /** Defines if half float texture linear filtering is supported*/
  34824. textureHalfFloatLinearFiltering: boolean;
  34825. /** Defines if rendering to half float textures is supported */
  34826. textureHalfFloatRender: boolean;
  34827. /** Defines if textureLOD shader command is supported */
  34828. textureLOD: boolean;
  34829. /** Defines if draw buffers extension is supported */
  34830. drawBuffersExtension: boolean;
  34831. /** Defines if depth textures are supported */
  34832. depthTextureExtension: boolean;
  34833. /** Defines if float color buffer are supported */
  34834. colorBufferFloat: boolean;
  34835. /** Gets disjoint timer query extension (null if not supported) */
  34836. timerQuery?: EXT_disjoint_timer_query;
  34837. /** Defines if timestamp can be used with timer query */
  34838. canUseTimestampForTimerQuery: boolean;
  34839. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34840. multiview?: any;
  34841. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34842. oculusMultiview?: any;
  34843. /** Function used to let the system compiles shaders in background */
  34844. parallelShaderCompile?: {
  34845. COMPLETION_STATUS_KHR: number;
  34846. };
  34847. /** Max number of texture samples for MSAA */
  34848. maxMSAASamples: number;
  34849. /** Defines if the blend min max extension is supported */
  34850. blendMinMax: boolean;
  34851. }
  34852. }
  34853. declare module BABYLON {
  34854. /**
  34855. * @hidden
  34856. **/
  34857. export class DepthCullingState {
  34858. private _isDepthTestDirty;
  34859. private _isDepthMaskDirty;
  34860. private _isDepthFuncDirty;
  34861. private _isCullFaceDirty;
  34862. private _isCullDirty;
  34863. private _isZOffsetDirty;
  34864. private _isFrontFaceDirty;
  34865. private _depthTest;
  34866. private _depthMask;
  34867. private _depthFunc;
  34868. private _cull;
  34869. private _cullFace;
  34870. private _zOffset;
  34871. private _frontFace;
  34872. /**
  34873. * Initializes the state.
  34874. */
  34875. constructor();
  34876. get isDirty(): boolean;
  34877. get zOffset(): number;
  34878. set zOffset(value: number);
  34879. get cullFace(): Nullable<number>;
  34880. set cullFace(value: Nullable<number>);
  34881. get cull(): Nullable<boolean>;
  34882. set cull(value: Nullable<boolean>);
  34883. get depthFunc(): Nullable<number>;
  34884. set depthFunc(value: Nullable<number>);
  34885. get depthMask(): boolean;
  34886. set depthMask(value: boolean);
  34887. get depthTest(): boolean;
  34888. set depthTest(value: boolean);
  34889. get frontFace(): Nullable<number>;
  34890. set frontFace(value: Nullable<number>);
  34891. reset(): void;
  34892. apply(gl: WebGLRenderingContext): void;
  34893. }
  34894. }
  34895. declare module BABYLON {
  34896. /**
  34897. * @hidden
  34898. **/
  34899. export class StencilState {
  34900. /** 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 */
  34901. static readonly ALWAYS: number;
  34902. /** Passed to stencilOperation to specify that stencil value must be kept */
  34903. static readonly KEEP: number;
  34904. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34905. static readonly REPLACE: number;
  34906. private _isStencilTestDirty;
  34907. private _isStencilMaskDirty;
  34908. private _isStencilFuncDirty;
  34909. private _isStencilOpDirty;
  34910. private _stencilTest;
  34911. private _stencilMask;
  34912. private _stencilFunc;
  34913. private _stencilFuncRef;
  34914. private _stencilFuncMask;
  34915. private _stencilOpStencilFail;
  34916. private _stencilOpDepthFail;
  34917. private _stencilOpStencilDepthPass;
  34918. get isDirty(): boolean;
  34919. get stencilFunc(): number;
  34920. set stencilFunc(value: number);
  34921. get stencilFuncRef(): number;
  34922. set stencilFuncRef(value: number);
  34923. get stencilFuncMask(): number;
  34924. set stencilFuncMask(value: number);
  34925. get stencilOpStencilFail(): number;
  34926. set stencilOpStencilFail(value: number);
  34927. get stencilOpDepthFail(): number;
  34928. set stencilOpDepthFail(value: number);
  34929. get stencilOpStencilDepthPass(): number;
  34930. set stencilOpStencilDepthPass(value: number);
  34931. get stencilMask(): number;
  34932. set stencilMask(value: number);
  34933. get stencilTest(): boolean;
  34934. set stencilTest(value: boolean);
  34935. constructor();
  34936. reset(): void;
  34937. apply(gl: WebGLRenderingContext): void;
  34938. }
  34939. }
  34940. declare module BABYLON {
  34941. /**
  34942. * @hidden
  34943. **/
  34944. export class AlphaState {
  34945. private _isAlphaBlendDirty;
  34946. private _isBlendFunctionParametersDirty;
  34947. private _isBlendEquationParametersDirty;
  34948. private _isBlendConstantsDirty;
  34949. private _alphaBlend;
  34950. private _blendFunctionParameters;
  34951. private _blendEquationParameters;
  34952. private _blendConstants;
  34953. /**
  34954. * Initializes the state.
  34955. */
  34956. constructor();
  34957. get isDirty(): boolean;
  34958. get alphaBlend(): boolean;
  34959. set alphaBlend(value: boolean);
  34960. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34961. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34962. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34963. reset(): void;
  34964. apply(gl: WebGLRenderingContext): void;
  34965. }
  34966. }
  34967. declare module BABYLON {
  34968. /** @hidden */
  34969. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34970. attributeProcessor(attribute: string): string;
  34971. varyingProcessor(varying: string, isFragment: boolean): string;
  34972. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34973. }
  34974. }
  34975. declare module BABYLON {
  34976. /**
  34977. * Interface for attribute information associated with buffer instanciation
  34978. */
  34979. export interface InstancingAttributeInfo {
  34980. /**
  34981. * Name of the GLSL attribute
  34982. * if attribute index is not specified, this is used to retrieve the index from the effect
  34983. */
  34984. attributeName: string;
  34985. /**
  34986. * Index/offset of the attribute in the vertex shader
  34987. * if not specified, this will be computes from the name.
  34988. */
  34989. index?: number;
  34990. /**
  34991. * size of the attribute, 1, 2, 3 or 4
  34992. */
  34993. attributeSize: number;
  34994. /**
  34995. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34996. */
  34997. offset: number;
  34998. /**
  34999. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35000. * default to 1
  35001. */
  35002. divisor?: number;
  35003. /**
  35004. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35005. * default is FLOAT
  35006. */
  35007. attributeType?: number;
  35008. /**
  35009. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35010. */
  35011. normalized?: boolean;
  35012. }
  35013. }
  35014. declare module BABYLON {
  35015. interface ThinEngine {
  35016. /**
  35017. * Update a video texture
  35018. * @param texture defines the texture to update
  35019. * @param video defines the video element to use
  35020. * @param invertY defines if data must be stored with Y axis inverted
  35021. */
  35022. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35023. }
  35024. }
  35025. declare module BABYLON {
  35026. interface ThinEngine {
  35027. /**
  35028. * Creates a dynamic texture
  35029. * @param width defines the width of the texture
  35030. * @param height defines the height of the texture
  35031. * @param generateMipMaps defines if the engine should generate the mip levels
  35032. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35033. * @returns the dynamic texture inside an InternalTexture
  35034. */
  35035. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35036. /**
  35037. * Update the content of a dynamic texture
  35038. * @param texture defines the texture to update
  35039. * @param canvas defines the canvas containing the source
  35040. * @param invertY defines if data must be stored with Y axis inverted
  35041. * @param premulAlpha defines if alpha is stored as premultiplied
  35042. * @param format defines the format of the data
  35043. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35044. */
  35045. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * Settings for finer control over video usage
  35051. */
  35052. export interface VideoTextureSettings {
  35053. /**
  35054. * Applies `autoplay` to video, if specified
  35055. */
  35056. autoPlay?: boolean;
  35057. /**
  35058. * Applies `loop` to video, if specified
  35059. */
  35060. loop?: boolean;
  35061. /**
  35062. * Automatically updates internal texture from video at every frame in the render loop
  35063. */
  35064. autoUpdateTexture: boolean;
  35065. /**
  35066. * Image src displayed during the video loading or until the user interacts with the video.
  35067. */
  35068. poster?: string;
  35069. }
  35070. /**
  35071. * If you want to display a video in your scene, this is the special texture for that.
  35072. * This special texture works similar to other textures, with the exception of a few parameters.
  35073. * @see https://doc.babylonjs.com/how_to/video_texture
  35074. */
  35075. export class VideoTexture extends Texture {
  35076. /**
  35077. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35078. */
  35079. readonly autoUpdateTexture: boolean;
  35080. /**
  35081. * The video instance used by the texture internally
  35082. */
  35083. readonly video: HTMLVideoElement;
  35084. private _onUserActionRequestedObservable;
  35085. /**
  35086. * Event triggerd when a dom action is required by the user to play the video.
  35087. * This happens due to recent changes in browser policies preventing video to auto start.
  35088. */
  35089. get onUserActionRequestedObservable(): Observable<Texture>;
  35090. private _generateMipMaps;
  35091. private _stillImageCaptured;
  35092. private _displayingPosterTexture;
  35093. private _settings;
  35094. private _createInternalTextureOnEvent;
  35095. private _frameId;
  35096. private _currentSrc;
  35097. /**
  35098. * Creates a video texture.
  35099. * If you want to display a video in your scene, this is the special texture for that.
  35100. * This special texture works similar to other textures, with the exception of a few parameters.
  35101. * @see https://doc.babylonjs.com/how_to/video_texture
  35102. * @param name optional name, will detect from video source, if not defined
  35103. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35104. * @param scene is obviously the current scene.
  35105. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35106. * @param invertY is false by default but can be used to invert video on Y axis
  35107. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35108. * @param settings allows finer control over video usage
  35109. */
  35110. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35111. private _getName;
  35112. private _getVideo;
  35113. private _createInternalTexture;
  35114. private reset;
  35115. /**
  35116. * @hidden Internal method to initiate `update`.
  35117. */
  35118. _rebuild(): void;
  35119. /**
  35120. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35121. */
  35122. update(): void;
  35123. /**
  35124. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35125. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35126. */
  35127. updateTexture(isVisible: boolean): void;
  35128. protected _updateInternalTexture: () => void;
  35129. /**
  35130. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35131. * @param url New url.
  35132. */
  35133. updateURL(url: string): void;
  35134. /**
  35135. * Clones the texture.
  35136. * @returns the cloned texture
  35137. */
  35138. clone(): VideoTexture;
  35139. /**
  35140. * Dispose the texture and release its associated resources.
  35141. */
  35142. dispose(): void;
  35143. /**
  35144. * Creates a video texture straight from a stream.
  35145. * @param scene Define the scene the texture should be created in
  35146. * @param stream Define the stream the texture should be created from
  35147. * @returns The created video texture as a promise
  35148. */
  35149. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35150. /**
  35151. * Creates a video texture straight from your WebCam video feed.
  35152. * @param scene Define the scene the texture should be created in
  35153. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35154. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35155. * @returns The created video texture as a promise
  35156. */
  35157. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35158. minWidth: number;
  35159. maxWidth: number;
  35160. minHeight: number;
  35161. maxHeight: number;
  35162. deviceId: string;
  35163. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35164. /**
  35165. * Creates a video texture straight from your WebCam video feed.
  35166. * @param scene Define the scene the texture should be created in
  35167. * @param onReady Define a callback to triggered once the texture will be ready
  35168. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35169. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35170. */
  35171. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35172. minWidth: number;
  35173. maxWidth: number;
  35174. minHeight: number;
  35175. maxHeight: number;
  35176. deviceId: string;
  35177. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35178. }
  35179. }
  35180. declare module BABYLON {
  35181. /**
  35182. * Defines the interface used by objects working like Scene
  35183. * @hidden
  35184. */
  35185. export interface ISceneLike {
  35186. _addPendingData(data: any): void;
  35187. _removePendingData(data: any): void;
  35188. offlineProvider: IOfflineProvider;
  35189. }
  35190. /**
  35191. * Information about the current host
  35192. */
  35193. export interface HostInformation {
  35194. /**
  35195. * Defines if the current host is a mobile
  35196. */
  35197. isMobile: boolean;
  35198. }
  35199. /** Interface defining initialization parameters for Engine class */
  35200. export interface EngineOptions extends WebGLContextAttributes {
  35201. /**
  35202. * Defines if the engine should no exceed a specified device ratio
  35203. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35204. */
  35205. limitDeviceRatio?: number;
  35206. /**
  35207. * Defines if webvr should be enabled automatically
  35208. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35209. */
  35210. autoEnableWebVR?: boolean;
  35211. /**
  35212. * Defines if webgl2 should be turned off even if supported
  35213. * @see https://doc.babylonjs.com/features/webgl2
  35214. */
  35215. disableWebGL2Support?: boolean;
  35216. /**
  35217. * Defines if webaudio should be initialized as well
  35218. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35219. */
  35220. audioEngine?: boolean;
  35221. /**
  35222. * Defines if animations should run using a deterministic lock step
  35223. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35224. */
  35225. deterministicLockstep?: boolean;
  35226. /** Defines the maximum steps to use with deterministic lock step mode */
  35227. lockstepMaxSteps?: number;
  35228. /** Defines the seconds between each deterministic lock step */
  35229. timeStep?: number;
  35230. /**
  35231. * Defines that engine should ignore context lost events
  35232. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35233. */
  35234. doNotHandleContextLost?: boolean;
  35235. /**
  35236. * Defines that engine should ignore modifying touch action attribute and style
  35237. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35238. */
  35239. doNotHandleTouchAction?: boolean;
  35240. /**
  35241. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35242. */
  35243. useHighPrecisionFloats?: boolean;
  35244. /**
  35245. * Make the canvas XR Compatible for XR sessions
  35246. */
  35247. xrCompatible?: boolean;
  35248. /**
  35249. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35250. */
  35251. useHighPrecisionMatrix?: boolean;
  35252. }
  35253. /**
  35254. * The base engine class (root of all engines)
  35255. */
  35256. export class ThinEngine {
  35257. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35258. static ExceptionList: ({
  35259. key: string;
  35260. capture: string;
  35261. captureConstraint: number;
  35262. targets: string[];
  35263. } | {
  35264. key: string;
  35265. capture: null;
  35266. captureConstraint: null;
  35267. targets: string[];
  35268. })[];
  35269. /** @hidden */
  35270. static _TextureLoaders: IInternalTextureLoader[];
  35271. /**
  35272. * Returns the current npm package of the sdk
  35273. */
  35274. static get NpmPackage(): string;
  35275. /**
  35276. * Returns the current version of the framework
  35277. */
  35278. static get Version(): string;
  35279. /**
  35280. * Returns a string describing the current engine
  35281. */
  35282. get description(): string;
  35283. /**
  35284. * Gets or sets the epsilon value used by collision engine
  35285. */
  35286. static CollisionsEpsilon: number;
  35287. /**
  35288. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35289. */
  35290. static get ShadersRepository(): string;
  35291. static set ShadersRepository(value: string);
  35292. /** @hidden */
  35293. _shaderProcessor: IShaderProcessor;
  35294. /**
  35295. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35296. */
  35297. forcePOTTextures: boolean;
  35298. /**
  35299. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35300. */
  35301. isFullscreen: boolean;
  35302. /**
  35303. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35304. */
  35305. cullBackFaces: boolean;
  35306. /**
  35307. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35308. */
  35309. renderEvenInBackground: boolean;
  35310. /**
  35311. * Gets or sets a boolean indicating that cache can be kept between frames
  35312. */
  35313. preventCacheWipeBetweenFrames: boolean;
  35314. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35315. validateShaderPrograms: boolean;
  35316. /**
  35317. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35318. * This can provide greater z depth for distant objects.
  35319. */
  35320. useReverseDepthBuffer: boolean;
  35321. /**
  35322. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35323. */
  35324. disableUniformBuffers: boolean;
  35325. /** @hidden */
  35326. _uniformBuffers: UniformBuffer[];
  35327. /**
  35328. * Gets a boolean indicating that the engine supports uniform buffers
  35329. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35330. */
  35331. get supportsUniformBuffers(): boolean;
  35332. /** @hidden */
  35333. _gl: WebGLRenderingContext;
  35334. /** @hidden */
  35335. _webGLVersion: number;
  35336. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35337. protected _windowIsBackground: boolean;
  35338. protected _creationOptions: EngineOptions;
  35339. protected _highPrecisionShadersAllowed: boolean;
  35340. /** @hidden */
  35341. get _shouldUseHighPrecisionShader(): boolean;
  35342. /**
  35343. * Gets a boolean indicating that only power of 2 textures are supported
  35344. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35345. */
  35346. get needPOTTextures(): boolean;
  35347. /** @hidden */
  35348. _badOS: boolean;
  35349. /** @hidden */
  35350. _badDesktopOS: boolean;
  35351. private _hardwareScalingLevel;
  35352. /** @hidden */
  35353. _caps: EngineCapabilities;
  35354. private _isStencilEnable;
  35355. private _glVersion;
  35356. private _glRenderer;
  35357. private _glVendor;
  35358. /** @hidden */
  35359. _videoTextureSupported: boolean;
  35360. protected _renderingQueueLaunched: boolean;
  35361. protected _activeRenderLoops: (() => void)[];
  35362. /**
  35363. * Observable signaled when a context lost event is raised
  35364. */
  35365. onContextLostObservable: Observable<ThinEngine>;
  35366. /**
  35367. * Observable signaled when a context restored event is raised
  35368. */
  35369. onContextRestoredObservable: Observable<ThinEngine>;
  35370. private _onContextLost;
  35371. private _onContextRestored;
  35372. protected _contextWasLost: boolean;
  35373. /** @hidden */
  35374. _doNotHandleContextLost: boolean;
  35375. /**
  35376. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35377. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35378. */
  35379. get doNotHandleContextLost(): boolean;
  35380. set doNotHandleContextLost(value: boolean);
  35381. /**
  35382. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35383. */
  35384. disableVertexArrayObjects: boolean;
  35385. /** @hidden */
  35386. protected _colorWrite: boolean;
  35387. /** @hidden */
  35388. protected _colorWriteChanged: boolean;
  35389. /** @hidden */
  35390. protected _depthCullingState: DepthCullingState;
  35391. /** @hidden */
  35392. protected _stencilState: StencilState;
  35393. /** @hidden */
  35394. _alphaState: AlphaState;
  35395. /** @hidden */
  35396. _alphaMode: number;
  35397. /** @hidden */
  35398. _alphaEquation: number;
  35399. /** @hidden */
  35400. _internalTexturesCache: InternalTexture[];
  35401. /** @hidden */
  35402. protected _activeChannel: number;
  35403. private _currentTextureChannel;
  35404. /** @hidden */
  35405. protected _boundTexturesCache: {
  35406. [key: string]: Nullable<InternalTexture>;
  35407. };
  35408. /** @hidden */
  35409. protected _currentEffect: Nullable<Effect>;
  35410. /** @hidden */
  35411. protected _currentProgram: Nullable<WebGLProgram>;
  35412. private _compiledEffects;
  35413. private _vertexAttribArraysEnabled;
  35414. /** @hidden */
  35415. protected _cachedViewport: Nullable<IViewportLike>;
  35416. private _cachedVertexArrayObject;
  35417. /** @hidden */
  35418. protected _cachedVertexBuffers: any;
  35419. /** @hidden */
  35420. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35421. /** @hidden */
  35422. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35423. /** @hidden */
  35424. _currentRenderTarget: Nullable<InternalTexture>;
  35425. private _uintIndicesCurrentlySet;
  35426. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35427. /** @hidden */
  35428. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35429. /** @hidden */
  35430. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35431. private _currentBufferPointers;
  35432. private _currentInstanceLocations;
  35433. private _currentInstanceBuffers;
  35434. private _textureUnits;
  35435. /** @hidden */
  35436. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35437. /** @hidden */
  35438. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35439. /** @hidden */
  35440. _boundRenderFunction: any;
  35441. private _vaoRecordInProgress;
  35442. private _mustWipeVertexAttributes;
  35443. private _emptyTexture;
  35444. private _emptyCubeTexture;
  35445. private _emptyTexture3D;
  35446. private _emptyTexture2DArray;
  35447. /** @hidden */
  35448. _frameHandler: number;
  35449. private _nextFreeTextureSlots;
  35450. private _maxSimultaneousTextures;
  35451. private _activeRequests;
  35452. /** @hidden */
  35453. _transformTextureUrl: Nullable<(url: string) => string>;
  35454. /**
  35455. * Gets information about the current host
  35456. */
  35457. hostInformation: HostInformation;
  35458. protected get _supportsHardwareTextureRescaling(): boolean;
  35459. private _framebufferDimensionsObject;
  35460. /**
  35461. * sets the object from which width and height will be taken from when getting render width and height
  35462. * Will fallback to the gl object
  35463. * @param dimensions the framebuffer width and height that will be used.
  35464. */
  35465. set framebufferDimensionsObject(dimensions: Nullable<{
  35466. framebufferWidth: number;
  35467. framebufferHeight: number;
  35468. }>);
  35469. /**
  35470. * Gets the current viewport
  35471. */
  35472. get currentViewport(): Nullable<IViewportLike>;
  35473. /**
  35474. * Gets the default empty texture
  35475. */
  35476. get emptyTexture(): InternalTexture;
  35477. /**
  35478. * Gets the default empty 3D texture
  35479. */
  35480. get emptyTexture3D(): InternalTexture;
  35481. /**
  35482. * Gets the default empty 2D array texture
  35483. */
  35484. get emptyTexture2DArray(): InternalTexture;
  35485. /**
  35486. * Gets the default empty cube texture
  35487. */
  35488. get emptyCubeTexture(): InternalTexture;
  35489. /**
  35490. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35491. */
  35492. readonly premultipliedAlpha: boolean;
  35493. /**
  35494. * Observable event triggered before each texture is initialized
  35495. */
  35496. onBeforeTextureInitObservable: Observable<Texture>;
  35497. /**
  35498. * Creates a new engine
  35499. * @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
  35500. * @param antialias defines enable antialiasing (default: false)
  35501. * @param options defines further options to be sent to the getContext() function
  35502. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35503. */
  35504. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35505. private _rebuildInternalTextures;
  35506. private _rebuildEffects;
  35507. /**
  35508. * Gets a boolean indicating if all created effects are ready
  35509. * @returns true if all effects are ready
  35510. */
  35511. areAllEffectsReady(): boolean;
  35512. protected _rebuildBuffers(): void;
  35513. protected _initGLContext(): void;
  35514. /**
  35515. * Gets version of the current webGL context
  35516. */
  35517. get webGLVersion(): number;
  35518. /**
  35519. * Gets a string identifying the name of the class
  35520. * @returns "Engine" string
  35521. */
  35522. getClassName(): string;
  35523. /**
  35524. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35525. */
  35526. get isStencilEnable(): boolean;
  35527. /** @hidden */
  35528. _prepareWorkingCanvas(): void;
  35529. /**
  35530. * Reset the texture cache to empty state
  35531. */
  35532. resetTextureCache(): void;
  35533. /**
  35534. * Gets an object containing information about the current webGL context
  35535. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35536. */
  35537. getGlInfo(): {
  35538. vendor: string;
  35539. renderer: string;
  35540. version: string;
  35541. };
  35542. /**
  35543. * Defines the hardware scaling level.
  35544. * By default the hardware scaling level is computed from the window device ratio.
  35545. * 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.
  35546. * @param level defines the level to use
  35547. */
  35548. setHardwareScalingLevel(level: number): void;
  35549. /**
  35550. * Gets the current hardware scaling level.
  35551. * By default the hardware scaling level is computed from the window device ratio.
  35552. * 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.
  35553. * @returns a number indicating the current hardware scaling level
  35554. */
  35555. getHardwareScalingLevel(): number;
  35556. /**
  35557. * Gets the list of loaded textures
  35558. * @returns an array containing all loaded textures
  35559. */
  35560. getLoadedTexturesCache(): InternalTexture[];
  35561. /**
  35562. * Gets the object containing all engine capabilities
  35563. * @returns the EngineCapabilities object
  35564. */
  35565. getCaps(): EngineCapabilities;
  35566. /**
  35567. * stop executing a render loop function and remove it from the execution array
  35568. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35569. */
  35570. stopRenderLoop(renderFunction?: () => void): void;
  35571. /** @hidden */
  35572. _renderLoop(): void;
  35573. /**
  35574. * Gets the HTML canvas attached with the current webGL context
  35575. * @returns a HTML canvas
  35576. */
  35577. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35578. /**
  35579. * Gets host window
  35580. * @returns the host window object
  35581. */
  35582. getHostWindow(): Nullable<Window>;
  35583. /**
  35584. * Gets the current render width
  35585. * @param useScreen defines if screen size must be used (or the current render target if any)
  35586. * @returns a number defining the current render width
  35587. */
  35588. getRenderWidth(useScreen?: boolean): number;
  35589. /**
  35590. * Gets the current render height
  35591. * @param useScreen defines if screen size must be used (or the current render target if any)
  35592. * @returns a number defining the current render height
  35593. */
  35594. getRenderHeight(useScreen?: boolean): number;
  35595. /**
  35596. * Can be used to override the current requestAnimationFrame requester.
  35597. * @hidden
  35598. */
  35599. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35600. /**
  35601. * Register and execute a render loop. The engine can have more than one render function
  35602. * @param renderFunction defines the function to continuously execute
  35603. */
  35604. runRenderLoop(renderFunction: () => void): void;
  35605. /**
  35606. * Clear the current render buffer or the current render target (if any is set up)
  35607. * @param color defines the color to use
  35608. * @param backBuffer defines if the back buffer must be cleared
  35609. * @param depth defines if the depth buffer must be cleared
  35610. * @param stencil defines if the stencil buffer must be cleared
  35611. */
  35612. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35613. private _viewportCached;
  35614. /** @hidden */
  35615. _viewport(x: number, y: number, width: number, height: number): void;
  35616. /**
  35617. * Set the WebGL's viewport
  35618. * @param viewport defines the viewport element to be used
  35619. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35620. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35621. */
  35622. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35623. /**
  35624. * Begin a new frame
  35625. */
  35626. beginFrame(): void;
  35627. /**
  35628. * Enf the current frame
  35629. */
  35630. endFrame(): void;
  35631. /**
  35632. * Resize the view according to the canvas' size
  35633. */
  35634. resize(): void;
  35635. /**
  35636. * Force a specific size of the canvas
  35637. * @param width defines the new canvas' width
  35638. * @param height defines the new canvas' height
  35639. * @returns true if the size was changed
  35640. */
  35641. setSize(width: number, height: number): boolean;
  35642. /**
  35643. * Binds the frame buffer to the specified texture.
  35644. * @param texture The texture to render to or null for the default canvas
  35645. * @param faceIndex The face of the texture to render to in case of cube texture
  35646. * @param requiredWidth The width of the target to render to
  35647. * @param requiredHeight The height of the target to render to
  35648. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35649. * @param lodLevel defines the lod level to bind to the frame buffer
  35650. * @param layer defines the 2d array index to bind to frame buffer to
  35651. */
  35652. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35653. /** @hidden */
  35654. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35655. /**
  35656. * Unbind the current render target texture from the webGL context
  35657. * @param texture defines the render target texture to unbind
  35658. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35659. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35660. */
  35661. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35662. /**
  35663. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35664. */
  35665. flushFramebuffer(): void;
  35666. /**
  35667. * Unbind the current render target and bind the default framebuffer
  35668. */
  35669. restoreDefaultFramebuffer(): void;
  35670. /** @hidden */
  35671. protected _resetVertexBufferBinding(): void;
  35672. /**
  35673. * Creates a vertex buffer
  35674. * @param data the data for the vertex buffer
  35675. * @returns the new WebGL static buffer
  35676. */
  35677. createVertexBuffer(data: DataArray): DataBuffer;
  35678. private _createVertexBuffer;
  35679. /**
  35680. * Creates a dynamic vertex buffer
  35681. * @param data the data for the dynamic vertex buffer
  35682. * @returns the new WebGL dynamic buffer
  35683. */
  35684. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35685. protected _resetIndexBufferBinding(): void;
  35686. /**
  35687. * Creates a new index buffer
  35688. * @param indices defines the content of the index buffer
  35689. * @param updatable defines if the index buffer must be updatable
  35690. * @returns a new webGL buffer
  35691. */
  35692. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35693. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35694. /**
  35695. * Bind a webGL buffer to the webGL context
  35696. * @param buffer defines the buffer to bind
  35697. */
  35698. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35699. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35700. private bindBuffer;
  35701. /**
  35702. * update the bound buffer with the given data
  35703. * @param data defines the data to update
  35704. */
  35705. updateArrayBuffer(data: Float32Array): void;
  35706. private _vertexAttribPointer;
  35707. /** @hidden */
  35708. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35709. private _bindVertexBuffersAttributes;
  35710. /**
  35711. * Records a vertex array object
  35712. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35713. * @param vertexBuffers defines the list of vertex buffers to store
  35714. * @param indexBuffer defines the index buffer to store
  35715. * @param effect defines the effect to store
  35716. * @returns the new vertex array object
  35717. */
  35718. recordVertexArrayObject(vertexBuffers: {
  35719. [key: string]: VertexBuffer;
  35720. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35721. /**
  35722. * Bind a specific vertex array object
  35723. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35724. * @param vertexArrayObject defines the vertex array object to bind
  35725. * @param indexBuffer defines the index buffer to bind
  35726. */
  35727. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35728. /**
  35729. * Bind webGl buffers directly to the webGL context
  35730. * @param vertexBuffer defines the vertex buffer to bind
  35731. * @param indexBuffer defines the index buffer to bind
  35732. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35733. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35734. * @param effect defines the effect associated with the vertex buffer
  35735. */
  35736. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35737. private _unbindVertexArrayObject;
  35738. /**
  35739. * Bind a list of vertex buffers to the webGL context
  35740. * @param vertexBuffers defines the list of vertex buffers to bind
  35741. * @param indexBuffer defines the index buffer to bind
  35742. * @param effect defines the effect associated with the vertex buffers
  35743. */
  35744. bindBuffers(vertexBuffers: {
  35745. [key: string]: Nullable<VertexBuffer>;
  35746. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35747. /**
  35748. * Unbind all instance attributes
  35749. */
  35750. unbindInstanceAttributes(): void;
  35751. /**
  35752. * Release and free the memory of a vertex array object
  35753. * @param vao defines the vertex array object to delete
  35754. */
  35755. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35756. /** @hidden */
  35757. _releaseBuffer(buffer: DataBuffer): boolean;
  35758. protected _deleteBuffer(buffer: DataBuffer): void;
  35759. /**
  35760. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35761. * @param instancesBuffer defines the webGL buffer to update and bind
  35762. * @param data defines the data to store in the buffer
  35763. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35764. */
  35765. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35766. /**
  35767. * Bind the content of a webGL buffer used with instantiation
  35768. * @param instancesBuffer defines the webGL buffer to bind
  35769. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35770. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35771. */
  35772. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35773. /**
  35774. * Disable the instance attribute corresponding to the name in parameter
  35775. * @param name defines the name of the attribute to disable
  35776. */
  35777. disableInstanceAttributeByName(name: string): void;
  35778. /**
  35779. * Disable the instance attribute corresponding to the location in parameter
  35780. * @param attributeLocation defines the attribute location of the attribute to disable
  35781. */
  35782. disableInstanceAttribute(attributeLocation: number): void;
  35783. /**
  35784. * Disable the attribute corresponding to the location in parameter
  35785. * @param attributeLocation defines the attribute location of the attribute to disable
  35786. */
  35787. disableAttributeByIndex(attributeLocation: number): void;
  35788. /**
  35789. * Send a draw order
  35790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35791. * @param indexStart defines the starting index
  35792. * @param indexCount defines the number of index to draw
  35793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35794. */
  35795. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35796. /**
  35797. * Draw a list of points
  35798. * @param verticesStart defines the index of first vertex to draw
  35799. * @param verticesCount defines the count of vertices to draw
  35800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35801. */
  35802. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35803. /**
  35804. * Draw a list of unindexed primitives
  35805. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35806. * @param verticesStart defines the index of first vertex to draw
  35807. * @param verticesCount defines the count of vertices to draw
  35808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35809. */
  35810. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35811. /**
  35812. * Draw a list of indexed primitives
  35813. * @param fillMode defines the primitive to use
  35814. * @param indexStart defines the starting index
  35815. * @param indexCount defines the number of index to draw
  35816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35817. */
  35818. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35819. /**
  35820. * Draw a list of unindexed primitives
  35821. * @param fillMode defines the primitive to use
  35822. * @param verticesStart defines the index of first vertex to draw
  35823. * @param verticesCount defines the count of vertices to draw
  35824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35825. */
  35826. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35827. private _drawMode;
  35828. /** @hidden */
  35829. protected _reportDrawCall(): void;
  35830. /** @hidden */
  35831. _releaseEffect(effect: Effect): void;
  35832. /** @hidden */
  35833. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35834. /**
  35835. * Create a new effect (used to store vertex/fragment shaders)
  35836. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35837. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35838. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35839. * @param samplers defines an array of string used to represent textures
  35840. * @param defines defines the string containing the defines to use to compile the shaders
  35841. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35842. * @param onCompiled defines a function to call when the effect creation is successful
  35843. * @param onError defines a function to call when the effect creation has failed
  35844. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35845. * @returns the new Effect
  35846. */
  35847. 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;
  35848. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35849. private _compileShader;
  35850. private _compileRawShader;
  35851. /** @hidden */
  35852. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35853. /**
  35854. * Directly creates a webGL program
  35855. * @param pipelineContext defines the pipeline context to attach to
  35856. * @param vertexCode defines the vertex shader code to use
  35857. * @param fragmentCode defines the fragment shader code to use
  35858. * @param context defines the webGL context to use (if not set, the current one will be used)
  35859. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35860. * @returns the new webGL program
  35861. */
  35862. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35863. /**
  35864. * Creates a webGL program
  35865. * @param pipelineContext defines the pipeline context to attach to
  35866. * @param vertexCode defines the vertex shader code to use
  35867. * @param fragmentCode defines the fragment shader code to use
  35868. * @param defines defines the string containing the defines to use to compile the shaders
  35869. * @param context defines the webGL context to use (if not set, the current one will be used)
  35870. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35871. * @returns the new webGL program
  35872. */
  35873. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35874. /**
  35875. * Creates a new pipeline context
  35876. * @returns the new pipeline
  35877. */
  35878. createPipelineContext(): IPipelineContext;
  35879. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35880. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35881. /** @hidden */
  35882. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35883. /** @hidden */
  35884. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35885. /** @hidden */
  35886. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35887. /**
  35888. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35889. * @param pipelineContext defines the pipeline context to use
  35890. * @param uniformsNames defines the list of uniform names
  35891. * @returns an array of webGL uniform locations
  35892. */
  35893. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35894. /**
  35895. * Gets the lsit of active attributes for a given webGL program
  35896. * @param pipelineContext defines the pipeline context to use
  35897. * @param attributesNames defines the list of attribute names to get
  35898. * @returns an array of indices indicating the offset of each attribute
  35899. */
  35900. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35901. /**
  35902. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35903. * @param effect defines the effect to activate
  35904. */
  35905. enableEffect(effect: Nullable<Effect>): void;
  35906. /**
  35907. * Set the value of an uniform to a number (int)
  35908. * @param uniform defines the webGL uniform location where to store the value
  35909. * @param value defines the int number to store
  35910. */
  35911. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35912. /**
  35913. * Set the value of an uniform to an array of int32
  35914. * @param uniform defines the webGL uniform location where to store the value
  35915. * @param array defines the array of int32 to store
  35916. */
  35917. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35918. /**
  35919. * Set the value of an uniform to an array of int32 (stored as vec2)
  35920. * @param uniform defines the webGL uniform location where to store the value
  35921. * @param array defines the array of int32 to store
  35922. */
  35923. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35924. /**
  35925. * Set the value of an uniform to an array of int32 (stored as vec3)
  35926. * @param uniform defines the webGL uniform location where to store the value
  35927. * @param array defines the array of int32 to store
  35928. */
  35929. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35930. /**
  35931. * Set the value of an uniform to an array of int32 (stored as vec4)
  35932. * @param uniform defines the webGL uniform location where to store the value
  35933. * @param array defines the array of int32 to store
  35934. */
  35935. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35936. /**
  35937. * Set the value of an uniform to an array of number
  35938. * @param uniform defines the webGL uniform location where to store the value
  35939. * @param array defines the array of number to store
  35940. */
  35941. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35942. /**
  35943. * Set the value of an uniform to an array of number (stored as vec2)
  35944. * @param uniform defines the webGL uniform location where to store the value
  35945. * @param array defines the array of number to store
  35946. */
  35947. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35948. /**
  35949. * Set the value of an uniform to an array of number (stored as vec3)
  35950. * @param uniform defines the webGL uniform location where to store the value
  35951. * @param array defines the array of number to store
  35952. */
  35953. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35954. /**
  35955. * Set the value of an uniform to an array of number (stored as vec4)
  35956. * @param uniform defines the webGL uniform location where to store the value
  35957. * @param array defines the array of number to store
  35958. */
  35959. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35960. /**
  35961. * Set the value of an uniform to an array of float32 (stored as matrices)
  35962. * @param uniform defines the webGL uniform location where to store the value
  35963. * @param matrices defines the array of float32 to store
  35964. */
  35965. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35966. /**
  35967. * Set the value of an uniform to a matrix (3x3)
  35968. * @param uniform defines the webGL uniform location where to store the value
  35969. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35970. */
  35971. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35972. /**
  35973. * Set the value of an uniform to a matrix (2x2)
  35974. * @param uniform defines the webGL uniform location where to store the value
  35975. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35976. */
  35977. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35978. /**
  35979. * Set the value of an uniform to a number (float)
  35980. * @param uniform defines the webGL uniform location where to store the value
  35981. * @param value defines the float number to store
  35982. */
  35983. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35984. /**
  35985. * Set the value of an uniform to a vec2
  35986. * @param uniform defines the webGL uniform location where to store the value
  35987. * @param x defines the 1st component of the value
  35988. * @param y defines the 2nd component of the value
  35989. */
  35990. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35991. /**
  35992. * Set the value of an uniform to a vec3
  35993. * @param uniform defines the webGL uniform location where to store the value
  35994. * @param x defines the 1st component of the value
  35995. * @param y defines the 2nd component of the value
  35996. * @param z defines the 3rd component of the value
  35997. */
  35998. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35999. /**
  36000. * Set the value of an uniform to a vec4
  36001. * @param uniform defines the webGL uniform location where to store the value
  36002. * @param x defines the 1st component of the value
  36003. * @param y defines the 2nd component of the value
  36004. * @param z defines the 3rd component of the value
  36005. * @param w defines the 4th component of the value
  36006. */
  36007. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36008. /**
  36009. * Apply all cached states (depth, culling, stencil and alpha)
  36010. */
  36011. applyStates(): void;
  36012. /**
  36013. * Enable or disable color writing
  36014. * @param enable defines the state to set
  36015. */
  36016. setColorWrite(enable: boolean): void;
  36017. /**
  36018. * Gets a boolean indicating if color writing is enabled
  36019. * @returns the current color writing state
  36020. */
  36021. getColorWrite(): boolean;
  36022. /**
  36023. * Gets the depth culling state manager
  36024. */
  36025. get depthCullingState(): DepthCullingState;
  36026. /**
  36027. * Gets the alpha state manager
  36028. */
  36029. get alphaState(): AlphaState;
  36030. /**
  36031. * Gets the stencil state manager
  36032. */
  36033. get stencilState(): StencilState;
  36034. /**
  36035. * Clears the list of texture accessible through engine.
  36036. * This can help preventing texture load conflict due to name collision.
  36037. */
  36038. clearInternalTexturesCache(): void;
  36039. /**
  36040. * Force the entire cache to be cleared
  36041. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36042. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36043. */
  36044. wipeCaches(bruteForce?: boolean): void;
  36045. /** @hidden */
  36046. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36047. min: number;
  36048. mag: number;
  36049. };
  36050. /** @hidden */
  36051. _createTexture(): WebGLTexture;
  36052. /**
  36053. * Usually called from Texture.ts.
  36054. * Passed information to create a WebGLTexture
  36055. * @param url defines a value which contains one of the following:
  36056. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36057. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36058. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36059. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36060. * @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)
  36061. * @param scene needed for loading to the correct scene
  36062. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36063. * @param onLoad optional callback to be called upon successful completion
  36064. * @param onError optional callback to be called upon failure
  36065. * @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
  36066. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36067. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36068. * @param forcedExtension defines the extension to use to pick the right loader
  36069. * @param mimeType defines an optional mime type
  36070. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36071. */
  36072. 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): InternalTexture;
  36073. /**
  36074. * Loads an image as an HTMLImageElement.
  36075. * @param input url string, ArrayBuffer, or Blob to load
  36076. * @param onLoad callback called when the image successfully loads
  36077. * @param onError callback called when the image fails to load
  36078. * @param offlineProvider offline provider for caching
  36079. * @param mimeType optional mime type
  36080. * @returns the HTMLImageElement of the loaded image
  36081. * @hidden
  36082. */
  36083. 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>;
  36084. /**
  36085. * @hidden
  36086. */
  36087. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36088. private _unpackFlipYCached;
  36089. /**
  36090. * In case you are sharing the context with other applications, it might
  36091. * be interested to not cache the unpack flip y state to ensure a consistent
  36092. * value would be set.
  36093. */
  36094. enableUnpackFlipYCached: boolean;
  36095. /** @hidden */
  36096. _unpackFlipY(value: boolean): void;
  36097. /** @hidden */
  36098. _getUnpackAlignement(): number;
  36099. private _getTextureTarget;
  36100. /**
  36101. * Update the sampling mode of a given texture
  36102. * @param samplingMode defines the required sampling mode
  36103. * @param texture defines the texture to update
  36104. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36105. */
  36106. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36107. /**
  36108. * Update the sampling mode of a given texture
  36109. * @param texture defines the texture to update
  36110. * @param wrapU defines the texture wrap mode of the u coordinates
  36111. * @param wrapV defines the texture wrap mode of the v coordinates
  36112. * @param wrapR defines the texture wrap mode of the r coordinates
  36113. */
  36114. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36115. /** @hidden */
  36116. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36117. width: number;
  36118. height: number;
  36119. layers?: number;
  36120. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36121. /** @hidden */
  36122. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36123. /** @hidden */
  36124. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36125. /**
  36126. * Update a portion of an internal texture
  36127. * @param texture defines the texture to update
  36128. * @param imageData defines the data to store into the texture
  36129. * @param xOffset defines the x coordinates of the update rectangle
  36130. * @param yOffset defines the y coordinates of the update rectangle
  36131. * @param width defines the width of the update rectangle
  36132. * @param height defines the height of the update rectangle
  36133. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36134. * @param lod defines the lod level to update (0 by default)
  36135. */
  36136. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36137. /** @hidden */
  36138. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36139. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36140. private _prepareWebGLTexture;
  36141. /** @hidden */
  36142. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36143. private _getDepthStencilBuffer;
  36144. /** @hidden */
  36145. _releaseFramebufferObjects(texture: InternalTexture): void;
  36146. /** @hidden */
  36147. _releaseTexture(texture: InternalTexture): void;
  36148. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36149. protected _setProgram(program: WebGLProgram): void;
  36150. protected _boundUniforms: {
  36151. [key: number]: WebGLUniformLocation;
  36152. };
  36153. /**
  36154. * Binds an effect to the webGL context
  36155. * @param effect defines the effect to bind
  36156. */
  36157. bindSamplers(effect: Effect): void;
  36158. private _activateCurrentTexture;
  36159. /** @hidden */
  36160. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36161. /** @hidden */
  36162. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36163. /**
  36164. * Unbind all textures from the webGL context
  36165. */
  36166. unbindAllTextures(): void;
  36167. /**
  36168. * Sets a texture to the according uniform.
  36169. * @param channel The texture channel
  36170. * @param uniform The uniform to set
  36171. * @param texture The texture to apply
  36172. */
  36173. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36174. private _bindSamplerUniformToChannel;
  36175. private _getTextureWrapMode;
  36176. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36177. /**
  36178. * Sets an array of texture to the webGL context
  36179. * @param channel defines the channel where the texture array must be set
  36180. * @param uniform defines the associated uniform location
  36181. * @param textures defines the array of textures to bind
  36182. */
  36183. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36184. /** @hidden */
  36185. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36186. private _setTextureParameterFloat;
  36187. private _setTextureParameterInteger;
  36188. /**
  36189. * Unbind all vertex attributes from the webGL context
  36190. */
  36191. unbindAllAttributes(): void;
  36192. /**
  36193. * 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
  36194. */
  36195. releaseEffects(): void;
  36196. /**
  36197. * Dispose and release all associated resources
  36198. */
  36199. dispose(): void;
  36200. /**
  36201. * Attach a new callback raised when context lost event is fired
  36202. * @param callback defines the callback to call
  36203. */
  36204. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36205. /**
  36206. * Attach a new callback raised when context restored event is fired
  36207. * @param callback defines the callback to call
  36208. */
  36209. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36210. /**
  36211. * Get the current error code of the webGL context
  36212. * @returns the error code
  36213. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36214. */
  36215. getError(): number;
  36216. private _canRenderToFloatFramebuffer;
  36217. private _canRenderToHalfFloatFramebuffer;
  36218. private _canRenderToFramebuffer;
  36219. /** @hidden */
  36220. _getWebGLTextureType(type: number): number;
  36221. /** @hidden */
  36222. _getInternalFormat(format: number): number;
  36223. /** @hidden */
  36224. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36225. /** @hidden */
  36226. _getRGBAMultiSampleBufferFormat(type: number): number;
  36227. /** @hidden */
  36228. _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;
  36229. /**
  36230. * Loads a file from a url
  36231. * @param url url to load
  36232. * @param onSuccess callback called when the file successfully loads
  36233. * @param onProgress callback called while file is loading (if the server supports this mode)
  36234. * @param offlineProvider defines the offline provider for caching
  36235. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36236. * @param onError callback called when the file fails to load
  36237. * @returns a file request object
  36238. * @hidden
  36239. */
  36240. 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;
  36241. /**
  36242. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36243. * @param x defines the x coordinate of the rectangle where pixels must be read
  36244. * @param y defines the y coordinate of the rectangle where pixels must be read
  36245. * @param width defines the width of the rectangle where pixels must be read
  36246. * @param height defines the height of the rectangle where pixels must be read
  36247. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36248. * @returns a Uint8Array containing RGBA colors
  36249. */
  36250. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36251. private static _isSupported;
  36252. /**
  36253. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36254. * @returns true if the engine can be created
  36255. * @ignorenaming
  36256. */
  36257. static isSupported(): boolean;
  36258. /**
  36259. * Find the next highest power of two.
  36260. * @param x Number to start search from.
  36261. * @return Next highest power of two.
  36262. */
  36263. static CeilingPOT(x: number): number;
  36264. /**
  36265. * Find the next lowest power of two.
  36266. * @param x Number to start search from.
  36267. * @return Next lowest power of two.
  36268. */
  36269. static FloorPOT(x: number): number;
  36270. /**
  36271. * Find the nearest power of two.
  36272. * @param x Number to start search from.
  36273. * @return Next nearest power of two.
  36274. */
  36275. static NearestPOT(x: number): number;
  36276. /**
  36277. * Get the closest exponent of two
  36278. * @param value defines the value to approximate
  36279. * @param max defines the maximum value to return
  36280. * @param mode defines how to define the closest value
  36281. * @returns closest exponent of two of the given value
  36282. */
  36283. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36284. /**
  36285. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36286. * @param func - the function to be called
  36287. * @param requester - the object that will request the next frame. Falls back to window.
  36288. * @returns frame number
  36289. */
  36290. static QueueNewFrame(func: () => void, requester?: any): number;
  36291. /**
  36292. * Gets host document
  36293. * @returns the host document object
  36294. */
  36295. getHostDocument(): Nullable<Document>;
  36296. }
  36297. }
  36298. declare module BABYLON {
  36299. /**
  36300. * Class representing spherical harmonics coefficients to the 3rd degree
  36301. */
  36302. export class SphericalHarmonics {
  36303. /**
  36304. * Defines whether or not the harmonics have been prescaled for rendering.
  36305. */
  36306. preScaled: boolean;
  36307. /**
  36308. * The l0,0 coefficients of the spherical harmonics
  36309. */
  36310. l00: Vector3;
  36311. /**
  36312. * The l1,-1 coefficients of the spherical harmonics
  36313. */
  36314. l1_1: Vector3;
  36315. /**
  36316. * The l1,0 coefficients of the spherical harmonics
  36317. */
  36318. l10: Vector3;
  36319. /**
  36320. * The l1,1 coefficients of the spherical harmonics
  36321. */
  36322. l11: Vector3;
  36323. /**
  36324. * The l2,-2 coefficients of the spherical harmonics
  36325. */
  36326. l2_2: Vector3;
  36327. /**
  36328. * The l2,-1 coefficients of the spherical harmonics
  36329. */
  36330. l2_1: Vector3;
  36331. /**
  36332. * The l2,0 coefficients of the spherical harmonics
  36333. */
  36334. l20: Vector3;
  36335. /**
  36336. * The l2,1 coefficients of the spherical harmonics
  36337. */
  36338. l21: Vector3;
  36339. /**
  36340. * The l2,2 coefficients of the spherical harmonics
  36341. */
  36342. l22: Vector3;
  36343. /**
  36344. * Adds a light to the spherical harmonics
  36345. * @param direction the direction of the light
  36346. * @param color the color of the light
  36347. * @param deltaSolidAngle the delta solid angle of the light
  36348. */
  36349. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36350. /**
  36351. * Scales the spherical harmonics by the given amount
  36352. * @param scale the amount to scale
  36353. */
  36354. scaleInPlace(scale: number): void;
  36355. /**
  36356. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36357. *
  36358. * ```
  36359. * E_lm = A_l * L_lm
  36360. * ```
  36361. *
  36362. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36363. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36364. * the scaling factors are given in equation 9.
  36365. */
  36366. convertIncidentRadianceToIrradiance(): void;
  36367. /**
  36368. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36369. *
  36370. * ```
  36371. * L = (1/pi) * E * rho
  36372. * ```
  36373. *
  36374. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36375. */
  36376. convertIrradianceToLambertianRadiance(): void;
  36377. /**
  36378. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36379. * required operations at run time.
  36380. *
  36381. * This is simply done by scaling back the SH with Ylm constants parameter.
  36382. * The trigonometric part being applied by the shader at run time.
  36383. */
  36384. preScaleForRendering(): void;
  36385. /**
  36386. * Constructs a spherical harmonics from an array.
  36387. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36388. * @returns the spherical harmonics
  36389. */
  36390. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36391. /**
  36392. * Gets the spherical harmonics from polynomial
  36393. * @param polynomial the spherical polynomial
  36394. * @returns the spherical harmonics
  36395. */
  36396. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36397. }
  36398. /**
  36399. * Class representing spherical polynomial coefficients to the 3rd degree
  36400. */
  36401. export class SphericalPolynomial {
  36402. private _harmonics;
  36403. /**
  36404. * The spherical harmonics used to create the polynomials.
  36405. */
  36406. get preScaledHarmonics(): SphericalHarmonics;
  36407. /**
  36408. * The x coefficients of the spherical polynomial
  36409. */
  36410. x: Vector3;
  36411. /**
  36412. * The y coefficients of the spherical polynomial
  36413. */
  36414. y: Vector3;
  36415. /**
  36416. * The z coefficients of the spherical polynomial
  36417. */
  36418. z: Vector3;
  36419. /**
  36420. * The xx coefficients of the spherical polynomial
  36421. */
  36422. xx: Vector3;
  36423. /**
  36424. * The yy coefficients of the spherical polynomial
  36425. */
  36426. yy: Vector3;
  36427. /**
  36428. * The zz coefficients of the spherical polynomial
  36429. */
  36430. zz: Vector3;
  36431. /**
  36432. * The xy coefficients of the spherical polynomial
  36433. */
  36434. xy: Vector3;
  36435. /**
  36436. * The yz coefficients of the spherical polynomial
  36437. */
  36438. yz: Vector3;
  36439. /**
  36440. * The zx coefficients of the spherical polynomial
  36441. */
  36442. zx: Vector3;
  36443. /**
  36444. * Adds an ambient color to the spherical polynomial
  36445. * @param color the color to add
  36446. */
  36447. addAmbient(color: Color3): void;
  36448. /**
  36449. * Scales the spherical polynomial by the given amount
  36450. * @param scale the amount to scale
  36451. */
  36452. scaleInPlace(scale: number): void;
  36453. /**
  36454. * Gets the spherical polynomial from harmonics
  36455. * @param harmonics the spherical harmonics
  36456. * @returns the spherical polynomial
  36457. */
  36458. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36459. /**
  36460. * Constructs a spherical polynomial from an array.
  36461. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36462. * @returns the spherical polynomial
  36463. */
  36464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36465. }
  36466. }
  36467. declare module BABYLON {
  36468. /**
  36469. * Defines the source of the internal texture
  36470. */
  36471. export enum InternalTextureSource {
  36472. /**
  36473. * The source of the texture data is unknown
  36474. */
  36475. Unknown = 0,
  36476. /**
  36477. * Texture data comes from an URL
  36478. */
  36479. Url = 1,
  36480. /**
  36481. * Texture data is only used for temporary storage
  36482. */
  36483. Temp = 2,
  36484. /**
  36485. * Texture data comes from raw data (ArrayBuffer)
  36486. */
  36487. Raw = 3,
  36488. /**
  36489. * Texture content is dynamic (video or dynamic texture)
  36490. */
  36491. Dynamic = 4,
  36492. /**
  36493. * Texture content is generated by rendering to it
  36494. */
  36495. RenderTarget = 5,
  36496. /**
  36497. * Texture content is part of a multi render target process
  36498. */
  36499. MultiRenderTarget = 6,
  36500. /**
  36501. * Texture data comes from a cube data file
  36502. */
  36503. Cube = 7,
  36504. /**
  36505. * Texture data comes from a raw cube data
  36506. */
  36507. CubeRaw = 8,
  36508. /**
  36509. * Texture data come from a prefiltered cube data file
  36510. */
  36511. CubePrefiltered = 9,
  36512. /**
  36513. * Texture content is raw 3D data
  36514. */
  36515. Raw3D = 10,
  36516. /**
  36517. * Texture content is raw 2D array data
  36518. */
  36519. Raw2DArray = 11,
  36520. /**
  36521. * Texture content is a depth texture
  36522. */
  36523. Depth = 12,
  36524. /**
  36525. * Texture data comes from a raw cube data encoded with RGBD
  36526. */
  36527. CubeRawRGBD = 13
  36528. }
  36529. /**
  36530. * Class used to store data associated with WebGL texture data for the engine
  36531. * This class should not be used directly
  36532. */
  36533. export class InternalTexture {
  36534. /** @hidden */
  36535. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36536. /**
  36537. * Defines if the texture is ready
  36538. */
  36539. isReady: boolean;
  36540. /**
  36541. * Defines if the texture is a cube texture
  36542. */
  36543. isCube: boolean;
  36544. /**
  36545. * Defines if the texture contains 3D data
  36546. */
  36547. is3D: boolean;
  36548. /**
  36549. * Defines if the texture contains 2D array data
  36550. */
  36551. is2DArray: boolean;
  36552. /**
  36553. * Defines if the texture contains multiview data
  36554. */
  36555. isMultiview: boolean;
  36556. /**
  36557. * Gets the URL used to load this texture
  36558. */
  36559. url: string;
  36560. /**
  36561. * Gets the sampling mode of the texture
  36562. */
  36563. samplingMode: number;
  36564. /**
  36565. * Gets a boolean indicating if the texture needs mipmaps generation
  36566. */
  36567. generateMipMaps: boolean;
  36568. /**
  36569. * Gets the number of samples used by the texture (WebGL2+ only)
  36570. */
  36571. samples: number;
  36572. /**
  36573. * Gets the type of the texture (int, float...)
  36574. */
  36575. type: number;
  36576. /**
  36577. * Gets the format of the texture (RGB, RGBA...)
  36578. */
  36579. format: number;
  36580. /**
  36581. * Observable called when the texture is loaded
  36582. */
  36583. onLoadedObservable: Observable<InternalTexture>;
  36584. /**
  36585. * Gets the width of the texture
  36586. */
  36587. width: number;
  36588. /**
  36589. * Gets the height of the texture
  36590. */
  36591. height: number;
  36592. /**
  36593. * Gets the depth of the texture
  36594. */
  36595. depth: number;
  36596. /**
  36597. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36598. */
  36599. baseWidth: number;
  36600. /**
  36601. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36602. */
  36603. baseHeight: number;
  36604. /**
  36605. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36606. */
  36607. baseDepth: number;
  36608. /**
  36609. * Gets a boolean indicating if the texture is inverted on Y axis
  36610. */
  36611. invertY: boolean;
  36612. /** @hidden */
  36613. _invertVScale: boolean;
  36614. /** @hidden */
  36615. _associatedChannel: number;
  36616. /** @hidden */
  36617. _source: InternalTextureSource;
  36618. /** @hidden */
  36619. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36620. /** @hidden */
  36621. _bufferView: Nullable<ArrayBufferView>;
  36622. /** @hidden */
  36623. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36624. /** @hidden */
  36625. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36626. /** @hidden */
  36627. _size: number;
  36628. /** @hidden */
  36629. _extension: string;
  36630. /** @hidden */
  36631. _files: Nullable<string[]>;
  36632. /** @hidden */
  36633. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36634. /** @hidden */
  36635. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36636. /** @hidden */
  36637. _framebuffer: Nullable<WebGLFramebuffer>;
  36638. /** @hidden */
  36639. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36640. /** @hidden */
  36641. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36642. /** @hidden */
  36643. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36644. /** @hidden */
  36645. _attachments: Nullable<number[]>;
  36646. /** @hidden */
  36647. _textureArray: Nullable<InternalTexture[]>;
  36648. /** @hidden */
  36649. _cachedCoordinatesMode: Nullable<number>;
  36650. /** @hidden */
  36651. _cachedWrapU: Nullable<number>;
  36652. /** @hidden */
  36653. _cachedWrapV: Nullable<number>;
  36654. /** @hidden */
  36655. _cachedWrapR: Nullable<number>;
  36656. /** @hidden */
  36657. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36658. /** @hidden */
  36659. _isDisabled: boolean;
  36660. /** @hidden */
  36661. _compression: Nullable<string>;
  36662. /** @hidden */
  36663. _generateStencilBuffer: boolean;
  36664. /** @hidden */
  36665. _generateDepthBuffer: boolean;
  36666. /** @hidden */
  36667. _comparisonFunction: number;
  36668. /** @hidden */
  36669. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36670. /** @hidden */
  36671. _lodGenerationScale: number;
  36672. /** @hidden */
  36673. _lodGenerationOffset: number;
  36674. /** @hidden */
  36675. _depthStencilTexture: Nullable<InternalTexture>;
  36676. /** @hidden */
  36677. _colorTextureArray: Nullable<WebGLTexture>;
  36678. /** @hidden */
  36679. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36680. /** @hidden */
  36681. _lodTextureHigh: Nullable<BaseTexture>;
  36682. /** @hidden */
  36683. _lodTextureMid: Nullable<BaseTexture>;
  36684. /** @hidden */
  36685. _lodTextureLow: Nullable<BaseTexture>;
  36686. /** @hidden */
  36687. _isRGBD: boolean;
  36688. /** @hidden */
  36689. _linearSpecularLOD: boolean;
  36690. /** @hidden */
  36691. _irradianceTexture: Nullable<BaseTexture>;
  36692. /** @hidden */
  36693. _webGLTexture: Nullable<WebGLTexture>;
  36694. /** @hidden */
  36695. _references: number;
  36696. /** @hidden */
  36697. _gammaSpace: Nullable<boolean>;
  36698. private _engine;
  36699. /**
  36700. * Gets the Engine the texture belongs to.
  36701. * @returns The babylon engine
  36702. */
  36703. getEngine(): ThinEngine;
  36704. /**
  36705. * Gets the data source type of the texture
  36706. */
  36707. get source(): InternalTextureSource;
  36708. /**
  36709. * Creates a new InternalTexture
  36710. * @param engine defines the engine to use
  36711. * @param source defines the type of data that will be used
  36712. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36713. */
  36714. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36715. /**
  36716. * Increments the number of references (ie. the number of Texture that point to it)
  36717. */
  36718. incrementReferences(): void;
  36719. /**
  36720. * Change the size of the texture (not the size of the content)
  36721. * @param width defines the new width
  36722. * @param height defines the new height
  36723. * @param depth defines the new depth (1 by default)
  36724. */
  36725. updateSize(width: int, height: int, depth?: int): void;
  36726. /** @hidden */
  36727. _rebuild(): void;
  36728. /** @hidden */
  36729. _swapAndDie(target: InternalTexture): void;
  36730. /**
  36731. * Dispose the current allocated resources
  36732. */
  36733. dispose(): void;
  36734. }
  36735. }
  36736. declare module BABYLON {
  36737. /**
  36738. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36739. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36740. */
  36741. export class Analyser {
  36742. /**
  36743. * Gets or sets the smoothing
  36744. * @ignorenaming
  36745. */
  36746. SMOOTHING: number;
  36747. /**
  36748. * Gets or sets the FFT table size
  36749. * @ignorenaming
  36750. */
  36751. FFT_SIZE: number;
  36752. /**
  36753. * Gets or sets the bar graph amplitude
  36754. * @ignorenaming
  36755. */
  36756. BARGRAPHAMPLITUDE: number;
  36757. /**
  36758. * Gets or sets the position of the debug canvas
  36759. * @ignorenaming
  36760. */
  36761. DEBUGCANVASPOS: {
  36762. x: number;
  36763. y: number;
  36764. };
  36765. /**
  36766. * Gets or sets the debug canvas size
  36767. * @ignorenaming
  36768. */
  36769. DEBUGCANVASSIZE: {
  36770. width: number;
  36771. height: number;
  36772. };
  36773. private _byteFreqs;
  36774. private _byteTime;
  36775. private _floatFreqs;
  36776. private _webAudioAnalyser;
  36777. private _debugCanvas;
  36778. private _debugCanvasContext;
  36779. private _scene;
  36780. private _registerFunc;
  36781. private _audioEngine;
  36782. /**
  36783. * Creates a new analyser
  36784. * @param scene defines hosting scene
  36785. */
  36786. constructor(scene: Scene);
  36787. /**
  36788. * Get the number of data values you will have to play with for the visualization
  36789. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36790. * @returns a number
  36791. */
  36792. getFrequencyBinCount(): number;
  36793. /**
  36794. * Gets the current frequency data as a byte array
  36795. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36796. * @returns a Uint8Array
  36797. */
  36798. getByteFrequencyData(): Uint8Array;
  36799. /**
  36800. * Gets the current waveform as a byte array
  36801. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36802. * @returns a Uint8Array
  36803. */
  36804. getByteTimeDomainData(): Uint8Array;
  36805. /**
  36806. * Gets the current frequency data as a float array
  36807. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36808. * @returns a Float32Array
  36809. */
  36810. getFloatFrequencyData(): Float32Array;
  36811. /**
  36812. * Renders the debug canvas
  36813. */
  36814. drawDebugCanvas(): void;
  36815. /**
  36816. * Stops rendering the debug canvas and removes it
  36817. */
  36818. stopDebugCanvas(): void;
  36819. /**
  36820. * Connects two audio nodes
  36821. * @param inputAudioNode defines first node to connect
  36822. * @param outputAudioNode defines second node to connect
  36823. */
  36824. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36825. /**
  36826. * Releases all associated resources
  36827. */
  36828. dispose(): void;
  36829. }
  36830. }
  36831. declare module BABYLON {
  36832. /**
  36833. * This represents an audio engine and it is responsible
  36834. * to play, synchronize and analyse sounds throughout the application.
  36835. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36836. */
  36837. export interface IAudioEngine extends IDisposable {
  36838. /**
  36839. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36840. */
  36841. readonly canUseWebAudio: boolean;
  36842. /**
  36843. * Gets the current AudioContext if available.
  36844. */
  36845. readonly audioContext: Nullable<AudioContext>;
  36846. /**
  36847. * The master gain node defines the global audio volume of your audio engine.
  36848. */
  36849. readonly masterGain: GainNode;
  36850. /**
  36851. * Gets whether or not mp3 are supported by your browser.
  36852. */
  36853. readonly isMP3supported: boolean;
  36854. /**
  36855. * Gets whether or not ogg are supported by your browser.
  36856. */
  36857. readonly isOGGsupported: boolean;
  36858. /**
  36859. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36860. * @ignoreNaming
  36861. */
  36862. WarnedWebAudioUnsupported: boolean;
  36863. /**
  36864. * Defines if the audio engine relies on a custom unlocked button.
  36865. * In this case, the embedded button will not be displayed.
  36866. */
  36867. useCustomUnlockedButton: boolean;
  36868. /**
  36869. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36870. */
  36871. readonly unlocked: boolean;
  36872. /**
  36873. * Event raised when audio has been unlocked on the browser.
  36874. */
  36875. onAudioUnlockedObservable: Observable<AudioEngine>;
  36876. /**
  36877. * Event raised when audio has been locked on the browser.
  36878. */
  36879. onAudioLockedObservable: Observable<AudioEngine>;
  36880. /**
  36881. * Flags the audio engine in Locked state.
  36882. * This happens due to new browser policies preventing audio to autoplay.
  36883. */
  36884. lock(): void;
  36885. /**
  36886. * Unlocks the audio engine once a user action has been done on the dom.
  36887. * This is helpful to resume play once browser policies have been satisfied.
  36888. */
  36889. unlock(): void;
  36890. /**
  36891. * Gets the global volume sets on the master gain.
  36892. * @returns the global volume if set or -1 otherwise
  36893. */
  36894. getGlobalVolume(): number;
  36895. /**
  36896. * Sets the global volume of your experience (sets on the master gain).
  36897. * @param newVolume Defines the new global volume of the application
  36898. */
  36899. setGlobalVolume(newVolume: number): void;
  36900. /**
  36901. * Connect the audio engine to an audio analyser allowing some amazing
  36902. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36903. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36904. * @param analyser The analyser to connect to the engine
  36905. */
  36906. connectToAnalyser(analyser: Analyser): void;
  36907. }
  36908. /**
  36909. * This represents the default audio engine used in babylon.
  36910. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36912. */
  36913. export class AudioEngine implements IAudioEngine {
  36914. private _audioContext;
  36915. private _audioContextInitialized;
  36916. private _muteButton;
  36917. private _hostElement;
  36918. /**
  36919. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36920. */
  36921. canUseWebAudio: boolean;
  36922. /**
  36923. * The master gain node defines the global audio volume of your audio engine.
  36924. */
  36925. masterGain: GainNode;
  36926. /**
  36927. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36928. * @ignoreNaming
  36929. */
  36930. WarnedWebAudioUnsupported: boolean;
  36931. /**
  36932. * Gets whether or not mp3 are supported by your browser.
  36933. */
  36934. isMP3supported: boolean;
  36935. /**
  36936. * Gets whether or not ogg are supported by your browser.
  36937. */
  36938. isOGGsupported: boolean;
  36939. /**
  36940. * Gets whether audio has been unlocked on the device.
  36941. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36942. * a user interaction has happened.
  36943. */
  36944. unlocked: boolean;
  36945. /**
  36946. * Defines if the audio engine relies on a custom unlocked button.
  36947. * In this case, the embedded button will not be displayed.
  36948. */
  36949. useCustomUnlockedButton: boolean;
  36950. /**
  36951. * Event raised when audio has been unlocked on the browser.
  36952. */
  36953. onAudioUnlockedObservable: Observable<AudioEngine>;
  36954. /**
  36955. * Event raised when audio has been locked on the browser.
  36956. */
  36957. onAudioLockedObservable: Observable<AudioEngine>;
  36958. /**
  36959. * Gets the current AudioContext if available.
  36960. */
  36961. get audioContext(): Nullable<AudioContext>;
  36962. private _connectedAnalyser;
  36963. /**
  36964. * Instantiates a new audio engine.
  36965. *
  36966. * There should be only one per page as some browsers restrict the number
  36967. * of audio contexts you can create.
  36968. * @param hostElement defines the host element where to display the mute icon if necessary
  36969. */
  36970. constructor(hostElement?: Nullable<HTMLElement>);
  36971. /**
  36972. * Flags the audio engine in Locked state.
  36973. * This happens due to new browser policies preventing audio to autoplay.
  36974. */
  36975. lock(): void;
  36976. /**
  36977. * Unlocks the audio engine once a user action has been done on the dom.
  36978. * This is helpful to resume play once browser policies have been satisfied.
  36979. */
  36980. unlock(): void;
  36981. private _resumeAudioContext;
  36982. private _initializeAudioContext;
  36983. private _tryToRun;
  36984. private _triggerRunningState;
  36985. private _triggerSuspendedState;
  36986. private _displayMuteButton;
  36987. private _moveButtonToTopLeft;
  36988. private _onResize;
  36989. private _hideMuteButton;
  36990. /**
  36991. * Destroy and release the resources associated with the audio ccontext.
  36992. */
  36993. dispose(): void;
  36994. /**
  36995. * Gets the global volume sets on the master gain.
  36996. * @returns the global volume if set or -1 otherwise
  36997. */
  36998. getGlobalVolume(): number;
  36999. /**
  37000. * Sets the global volume of your experience (sets on the master gain).
  37001. * @param newVolume Defines the new global volume of the application
  37002. */
  37003. setGlobalVolume(newVolume: number): void;
  37004. /**
  37005. * Connect the audio engine to an audio analyser allowing some amazing
  37006. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37008. * @param analyser The analyser to connect to the engine
  37009. */
  37010. connectToAnalyser(analyser: Analyser): void;
  37011. }
  37012. }
  37013. declare module BABYLON {
  37014. /**
  37015. * Interface used to present a loading screen while loading a scene
  37016. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37017. */
  37018. export interface ILoadingScreen {
  37019. /**
  37020. * Function called to display the loading screen
  37021. */
  37022. displayLoadingUI: () => void;
  37023. /**
  37024. * Function called to hide the loading screen
  37025. */
  37026. hideLoadingUI: () => void;
  37027. /**
  37028. * Gets or sets the color to use for the background
  37029. */
  37030. loadingUIBackgroundColor: string;
  37031. /**
  37032. * Gets or sets the text to display while loading
  37033. */
  37034. loadingUIText: string;
  37035. }
  37036. /**
  37037. * Class used for the default loading screen
  37038. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37039. */
  37040. export class DefaultLoadingScreen implements ILoadingScreen {
  37041. private _renderingCanvas;
  37042. private _loadingText;
  37043. private _loadingDivBackgroundColor;
  37044. private _loadingDiv;
  37045. private _loadingTextDiv;
  37046. /** Gets or sets the logo url to use for the default loading screen */
  37047. static DefaultLogoUrl: string;
  37048. /** Gets or sets the spinner url to use for the default loading screen */
  37049. static DefaultSpinnerUrl: string;
  37050. /**
  37051. * Creates a new default loading screen
  37052. * @param _renderingCanvas defines the canvas used to render the scene
  37053. * @param _loadingText defines the default text to display
  37054. * @param _loadingDivBackgroundColor defines the default background color
  37055. */
  37056. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37057. /**
  37058. * Function called to display the loading screen
  37059. */
  37060. displayLoadingUI(): void;
  37061. /**
  37062. * Function called to hide the loading screen
  37063. */
  37064. hideLoadingUI(): void;
  37065. /**
  37066. * Gets or sets the text to display while loading
  37067. */
  37068. set loadingUIText(text: string);
  37069. get loadingUIText(): string;
  37070. /**
  37071. * Gets or sets the color to use for the background
  37072. */
  37073. get loadingUIBackgroundColor(): string;
  37074. set loadingUIBackgroundColor(color: string);
  37075. private _resizeLoadingUI;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /**
  37080. * Interface for any object that can request an animation frame
  37081. */
  37082. export interface ICustomAnimationFrameRequester {
  37083. /**
  37084. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37085. */
  37086. renderFunction?: Function;
  37087. /**
  37088. * Called to request the next frame to render to
  37089. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37090. */
  37091. requestAnimationFrame: Function;
  37092. /**
  37093. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37094. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37095. */
  37096. requestID?: number;
  37097. }
  37098. }
  37099. declare module BABYLON {
  37100. /**
  37101. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37102. */
  37103. export class PerformanceMonitor {
  37104. private _enabled;
  37105. private _rollingFrameTime;
  37106. private _lastFrameTimeMs;
  37107. /**
  37108. * constructor
  37109. * @param frameSampleSize The number of samples required to saturate the sliding window
  37110. */
  37111. constructor(frameSampleSize?: number);
  37112. /**
  37113. * Samples current frame
  37114. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37115. */
  37116. sampleFrame(timeMs?: number): void;
  37117. /**
  37118. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37119. */
  37120. get averageFrameTime(): number;
  37121. /**
  37122. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37123. */
  37124. get averageFrameTimeVariance(): number;
  37125. /**
  37126. * Returns the frame time of the most recent frame
  37127. */
  37128. get instantaneousFrameTime(): number;
  37129. /**
  37130. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37131. */
  37132. get averageFPS(): number;
  37133. /**
  37134. * Returns the average framerate in frames per second using the most recent frame time
  37135. */
  37136. get instantaneousFPS(): number;
  37137. /**
  37138. * Returns true if enough samples have been taken to completely fill the sliding window
  37139. */
  37140. get isSaturated(): boolean;
  37141. /**
  37142. * Enables contributions to the sliding window sample set
  37143. */
  37144. enable(): void;
  37145. /**
  37146. * Disables contributions to the sliding window sample set
  37147. * Samples will not be interpolated over the disabled period
  37148. */
  37149. disable(): void;
  37150. /**
  37151. * Returns true if sampling is enabled
  37152. */
  37153. get isEnabled(): boolean;
  37154. /**
  37155. * Resets performance monitor
  37156. */
  37157. reset(): void;
  37158. }
  37159. /**
  37160. * RollingAverage
  37161. *
  37162. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37163. */
  37164. export class RollingAverage {
  37165. /**
  37166. * Current average
  37167. */
  37168. average: number;
  37169. /**
  37170. * Current variance
  37171. */
  37172. variance: number;
  37173. protected _samples: Array<number>;
  37174. protected _sampleCount: number;
  37175. protected _pos: number;
  37176. protected _m2: number;
  37177. /**
  37178. * constructor
  37179. * @param length The number of samples required to saturate the sliding window
  37180. */
  37181. constructor(length: number);
  37182. /**
  37183. * Adds a sample to the sample set
  37184. * @param v The sample value
  37185. */
  37186. add(v: number): void;
  37187. /**
  37188. * Returns previously added values or null if outside of history or outside the sliding window domain
  37189. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37190. * @return Value previously recorded with add() or null if outside of range
  37191. */
  37192. history(i: number): number;
  37193. /**
  37194. * Returns true if enough samples have been taken to completely fill the sliding window
  37195. * @return true if sample-set saturated
  37196. */
  37197. isSaturated(): boolean;
  37198. /**
  37199. * Resets the rolling average (equivalent to 0 samples taken so far)
  37200. */
  37201. reset(): void;
  37202. /**
  37203. * Wraps a value around the sample range boundaries
  37204. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37205. * @return Wrapped position in sample range
  37206. */
  37207. protected _wrapPosition(i: number): number;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. /**
  37212. * This class is used to track a performance counter which is number based.
  37213. * The user has access to many properties which give statistics of different nature.
  37214. *
  37215. * The implementer can track two kinds of Performance Counter: time and count.
  37216. * 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.
  37217. * 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.
  37218. */
  37219. export class PerfCounter {
  37220. /**
  37221. * Gets or sets a global boolean to turn on and off all the counters
  37222. */
  37223. static Enabled: boolean;
  37224. /**
  37225. * Returns the smallest value ever
  37226. */
  37227. get min(): number;
  37228. /**
  37229. * Returns the biggest value ever
  37230. */
  37231. get max(): number;
  37232. /**
  37233. * Returns the average value since the performance counter is running
  37234. */
  37235. get average(): number;
  37236. /**
  37237. * Returns the average value of the last second the counter was monitored
  37238. */
  37239. get lastSecAverage(): number;
  37240. /**
  37241. * Returns the current value
  37242. */
  37243. get current(): number;
  37244. /**
  37245. * Gets the accumulated total
  37246. */
  37247. get total(): number;
  37248. /**
  37249. * Gets the total value count
  37250. */
  37251. get count(): number;
  37252. /**
  37253. * Creates a new counter
  37254. */
  37255. constructor();
  37256. /**
  37257. * Call this method to start monitoring a new frame.
  37258. * 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.
  37259. */
  37260. fetchNewFrame(): void;
  37261. /**
  37262. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37263. * @param newCount the count value to add to the monitored count
  37264. * @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.
  37265. */
  37266. addCount(newCount: number, fetchResult: boolean): void;
  37267. /**
  37268. * Start monitoring this performance counter
  37269. */
  37270. beginMonitoring(): void;
  37271. /**
  37272. * Compute the time lapsed since the previous beginMonitoring() call.
  37273. * @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
  37274. */
  37275. endMonitoring(newFrame?: boolean): void;
  37276. private _fetchResult;
  37277. private _startMonitoringTime;
  37278. private _min;
  37279. private _max;
  37280. private _average;
  37281. private _current;
  37282. private _totalValueCount;
  37283. private _totalAccumulated;
  37284. private _lastSecAverage;
  37285. private _lastSecAccumulated;
  37286. private _lastSecTime;
  37287. private _lastSecValueCount;
  37288. }
  37289. }
  37290. declare module BABYLON {
  37291. interface ThinEngine {
  37292. /** @hidden */
  37293. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37294. }
  37295. }
  37296. declare module BABYLON {
  37297. /**
  37298. * Defines the interface used by display changed events
  37299. */
  37300. export interface IDisplayChangedEventArgs {
  37301. /** Gets the vrDisplay object (if any) */
  37302. vrDisplay: Nullable<any>;
  37303. /** Gets a boolean indicating if webVR is supported */
  37304. vrSupported: boolean;
  37305. }
  37306. /**
  37307. * Defines the interface used by objects containing a viewport (like a camera)
  37308. */
  37309. interface IViewportOwnerLike {
  37310. /**
  37311. * Gets or sets the viewport
  37312. */
  37313. viewport: IViewportLike;
  37314. }
  37315. /**
  37316. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37317. */
  37318. export class Engine extends ThinEngine {
  37319. /** Defines that alpha blending is disabled */
  37320. static readonly ALPHA_DISABLE: number;
  37321. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37322. static readonly ALPHA_ADD: number;
  37323. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37324. static readonly ALPHA_COMBINE: number;
  37325. /** Defines that alpha blending to DEST - SRC * DEST */
  37326. static readonly ALPHA_SUBTRACT: number;
  37327. /** Defines that alpha blending to SRC * DEST */
  37328. static readonly ALPHA_MULTIPLY: number;
  37329. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37330. static readonly ALPHA_MAXIMIZED: number;
  37331. /** Defines that alpha blending to SRC + DEST */
  37332. static readonly ALPHA_ONEONE: number;
  37333. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37334. static readonly ALPHA_PREMULTIPLIED: number;
  37335. /**
  37336. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37337. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37338. */
  37339. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37340. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37341. static readonly ALPHA_INTERPOLATE: number;
  37342. /**
  37343. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37344. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37345. */
  37346. static readonly ALPHA_SCREENMODE: number;
  37347. /** Defines that the ressource is not delayed*/
  37348. static readonly DELAYLOADSTATE_NONE: number;
  37349. /** Defines that the ressource was successfully delay loaded */
  37350. static readonly DELAYLOADSTATE_LOADED: number;
  37351. /** Defines that the ressource is currently delay loading */
  37352. static readonly DELAYLOADSTATE_LOADING: number;
  37353. /** Defines that the ressource is delayed and has not started loading */
  37354. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37356. static readonly NEVER: number;
  37357. /** 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 */
  37358. static readonly ALWAYS: number;
  37359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37360. static readonly LESS: number;
  37361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37362. static readonly EQUAL: number;
  37363. /** 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 */
  37364. static readonly LEQUAL: number;
  37365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37366. static readonly GREATER: number;
  37367. /** 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 */
  37368. static readonly GEQUAL: number;
  37369. /** 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 */
  37370. static readonly NOTEQUAL: number;
  37371. /** Passed to stencilOperation to specify that stencil value must be kept */
  37372. static readonly KEEP: number;
  37373. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37374. static readonly REPLACE: number;
  37375. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37376. static readonly INCR: number;
  37377. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37378. static readonly DECR: number;
  37379. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37380. static readonly INVERT: number;
  37381. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37382. static readonly INCR_WRAP: number;
  37383. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37384. static readonly DECR_WRAP: number;
  37385. /** Texture is not repeating outside of 0..1 UVs */
  37386. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37387. /** Texture is repeating outside of 0..1 UVs */
  37388. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37389. /** Texture is repeating and mirrored */
  37390. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37391. /** ALPHA */
  37392. static readonly TEXTUREFORMAT_ALPHA: number;
  37393. /** LUMINANCE */
  37394. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37395. /** LUMINANCE_ALPHA */
  37396. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37397. /** RGB */
  37398. static readonly TEXTUREFORMAT_RGB: number;
  37399. /** RGBA */
  37400. static readonly TEXTUREFORMAT_RGBA: number;
  37401. /** RED */
  37402. static readonly TEXTUREFORMAT_RED: number;
  37403. /** RED (2nd reference) */
  37404. static readonly TEXTUREFORMAT_R: number;
  37405. /** RG */
  37406. static readonly TEXTUREFORMAT_RG: number;
  37407. /** RED_INTEGER */
  37408. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37409. /** RED_INTEGER (2nd reference) */
  37410. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37411. /** RG_INTEGER */
  37412. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37413. /** RGB_INTEGER */
  37414. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37415. /** RGBA_INTEGER */
  37416. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37417. /** UNSIGNED_BYTE */
  37418. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37419. /** UNSIGNED_BYTE (2nd reference) */
  37420. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37421. /** FLOAT */
  37422. static readonly TEXTURETYPE_FLOAT: number;
  37423. /** HALF_FLOAT */
  37424. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37425. /** BYTE */
  37426. static readonly TEXTURETYPE_BYTE: number;
  37427. /** SHORT */
  37428. static readonly TEXTURETYPE_SHORT: number;
  37429. /** UNSIGNED_SHORT */
  37430. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37431. /** INT */
  37432. static readonly TEXTURETYPE_INT: number;
  37433. /** UNSIGNED_INT */
  37434. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37435. /** UNSIGNED_SHORT_4_4_4_4 */
  37436. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37437. /** UNSIGNED_SHORT_5_5_5_1 */
  37438. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37439. /** UNSIGNED_SHORT_5_6_5 */
  37440. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37441. /** UNSIGNED_INT_2_10_10_10_REV */
  37442. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37443. /** UNSIGNED_INT_24_8 */
  37444. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37445. /** UNSIGNED_INT_10F_11F_11F_REV */
  37446. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37447. /** UNSIGNED_INT_5_9_9_9_REV */
  37448. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37449. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37450. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37451. /** nearest is mag = nearest and min = nearest and mip = linear */
  37452. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37453. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37454. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37455. /** Trilinear is mag = linear and min = linear and mip = linear */
  37456. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37457. /** nearest is mag = nearest and min = nearest and mip = linear */
  37458. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37459. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37460. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37461. /** Trilinear is mag = linear and min = linear and mip = linear */
  37462. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37463. /** mag = nearest and min = nearest and mip = nearest */
  37464. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37465. /** mag = nearest and min = linear and mip = nearest */
  37466. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37467. /** mag = nearest and min = linear and mip = linear */
  37468. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37469. /** mag = nearest and min = linear and mip = none */
  37470. static readonly TEXTURE_NEAREST_LINEAR: number;
  37471. /** mag = nearest and min = nearest and mip = none */
  37472. static readonly TEXTURE_NEAREST_NEAREST: number;
  37473. /** mag = linear and min = nearest and mip = nearest */
  37474. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37475. /** mag = linear and min = nearest and mip = linear */
  37476. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37477. /** mag = linear and min = linear and mip = none */
  37478. static readonly TEXTURE_LINEAR_LINEAR: number;
  37479. /** mag = linear and min = nearest and mip = none */
  37480. static readonly TEXTURE_LINEAR_NEAREST: number;
  37481. /** Explicit coordinates mode */
  37482. static readonly TEXTURE_EXPLICIT_MODE: number;
  37483. /** Spherical coordinates mode */
  37484. static readonly TEXTURE_SPHERICAL_MODE: number;
  37485. /** Planar coordinates mode */
  37486. static readonly TEXTURE_PLANAR_MODE: number;
  37487. /** Cubic coordinates mode */
  37488. static readonly TEXTURE_CUBIC_MODE: number;
  37489. /** Projection coordinates mode */
  37490. static readonly TEXTURE_PROJECTION_MODE: number;
  37491. /** Skybox coordinates mode */
  37492. static readonly TEXTURE_SKYBOX_MODE: number;
  37493. /** Inverse Cubic coordinates mode */
  37494. static readonly TEXTURE_INVCUBIC_MODE: number;
  37495. /** Equirectangular coordinates mode */
  37496. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37497. /** Equirectangular Fixed coordinates mode */
  37498. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37499. /** Equirectangular Fixed Mirrored coordinates mode */
  37500. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37501. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37502. static readonly SCALEMODE_FLOOR: number;
  37503. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37504. static readonly SCALEMODE_NEAREST: number;
  37505. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37506. static readonly SCALEMODE_CEILING: number;
  37507. /**
  37508. * Returns the current npm package of the sdk
  37509. */
  37510. static get NpmPackage(): string;
  37511. /**
  37512. * Returns the current version of the framework
  37513. */
  37514. static get Version(): string;
  37515. /** Gets the list of created engines */
  37516. static get Instances(): Engine[];
  37517. /**
  37518. * Gets the latest created engine
  37519. */
  37520. static get LastCreatedEngine(): Nullable<Engine>;
  37521. /**
  37522. * Gets the latest created scene
  37523. */
  37524. static get LastCreatedScene(): Nullable<Scene>;
  37525. /**
  37526. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37527. * @param flag defines which part of the materials must be marked as dirty
  37528. * @param predicate defines a predicate used to filter which materials should be affected
  37529. */
  37530. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37531. /**
  37532. * Method called to create the default loading screen.
  37533. * This can be overriden in your own app.
  37534. * @param canvas The rendering canvas element
  37535. * @returns The loading screen
  37536. */
  37537. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37538. /**
  37539. * Method called to create the default rescale post process on each engine.
  37540. */
  37541. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37542. /**
  37543. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37544. **/
  37545. enableOfflineSupport: boolean;
  37546. /**
  37547. * 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)
  37548. **/
  37549. disableManifestCheck: boolean;
  37550. /**
  37551. * Gets the list of created scenes
  37552. */
  37553. scenes: Scene[];
  37554. /**
  37555. * Event raised when a new scene is created
  37556. */
  37557. onNewSceneAddedObservable: Observable<Scene>;
  37558. /**
  37559. * Gets the list of created postprocesses
  37560. */
  37561. postProcesses: PostProcess[];
  37562. /**
  37563. * Gets a boolean indicating if the pointer is currently locked
  37564. */
  37565. isPointerLock: boolean;
  37566. /**
  37567. * Observable event triggered each time the rendering canvas is resized
  37568. */
  37569. onResizeObservable: Observable<Engine>;
  37570. /**
  37571. * Observable event triggered each time the canvas loses focus
  37572. */
  37573. onCanvasBlurObservable: Observable<Engine>;
  37574. /**
  37575. * Observable event triggered each time the canvas gains focus
  37576. */
  37577. onCanvasFocusObservable: Observable<Engine>;
  37578. /**
  37579. * Observable event triggered each time the canvas receives pointerout event
  37580. */
  37581. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37582. /**
  37583. * Observable raised when the engine begins a new frame
  37584. */
  37585. onBeginFrameObservable: Observable<Engine>;
  37586. /**
  37587. * If set, will be used to request the next animation frame for the render loop
  37588. */
  37589. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37590. /**
  37591. * Observable raised when the engine ends the current frame
  37592. */
  37593. onEndFrameObservable: Observable<Engine>;
  37594. /**
  37595. * Observable raised when the engine is about to compile a shader
  37596. */
  37597. onBeforeShaderCompilationObservable: Observable<Engine>;
  37598. /**
  37599. * Observable raised when the engine has jsut compiled a shader
  37600. */
  37601. onAfterShaderCompilationObservable: Observable<Engine>;
  37602. /**
  37603. * Gets the audio engine
  37604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37605. * @ignorenaming
  37606. */
  37607. static audioEngine: IAudioEngine;
  37608. /**
  37609. * Default AudioEngine factory responsible of creating the Audio Engine.
  37610. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37611. */
  37612. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37613. /**
  37614. * Default offline support factory responsible of creating a tool used to store data locally.
  37615. * By default, this will create a Database object if the workload has been embedded.
  37616. */
  37617. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37618. private _loadingScreen;
  37619. private _pointerLockRequested;
  37620. private _rescalePostProcess;
  37621. private _deterministicLockstep;
  37622. private _lockstepMaxSteps;
  37623. private _timeStep;
  37624. protected get _supportsHardwareTextureRescaling(): boolean;
  37625. private _fps;
  37626. private _deltaTime;
  37627. /** @hidden */
  37628. _drawCalls: PerfCounter;
  37629. /** 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 */
  37630. canvasTabIndex: number;
  37631. /**
  37632. * Turn this value on if you want to pause FPS computation when in background
  37633. */
  37634. disablePerformanceMonitorInBackground: boolean;
  37635. private _performanceMonitor;
  37636. /**
  37637. * Gets the performance monitor attached to this engine
  37638. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37639. */
  37640. get performanceMonitor(): PerformanceMonitor;
  37641. private _onFocus;
  37642. private _onBlur;
  37643. private _onCanvasPointerOut;
  37644. private _onCanvasBlur;
  37645. private _onCanvasFocus;
  37646. private _onFullscreenChange;
  37647. private _onPointerLockChange;
  37648. /**
  37649. * Gets the HTML element used to attach event listeners
  37650. * @returns a HTML element
  37651. */
  37652. getInputElement(): Nullable<HTMLElement>;
  37653. /**
  37654. * Creates a new engine
  37655. * @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
  37656. * @param antialias defines enable antialiasing (default: false)
  37657. * @param options defines further options to be sent to the getContext() function
  37658. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37659. */
  37660. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37661. /**
  37662. * Gets current aspect ratio
  37663. * @param viewportOwner defines the camera to use to get the aspect ratio
  37664. * @param useScreen defines if screen size must be used (or the current render target if any)
  37665. * @returns a number defining the aspect ratio
  37666. */
  37667. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37668. /**
  37669. * Gets current screen aspect ratio
  37670. * @returns a number defining the aspect ratio
  37671. */
  37672. getScreenAspectRatio(): number;
  37673. /**
  37674. * Gets the client rect of the HTML canvas attached with the current webGL context
  37675. * @returns a client rectanglee
  37676. */
  37677. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37678. /**
  37679. * Gets the client rect of the HTML element used for events
  37680. * @returns a client rectanglee
  37681. */
  37682. getInputElementClientRect(): Nullable<ClientRect>;
  37683. /**
  37684. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37685. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37686. * @returns true if engine is in deterministic lock step mode
  37687. */
  37688. isDeterministicLockStep(): boolean;
  37689. /**
  37690. * Gets the max steps when engine is running in deterministic lock step
  37691. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37692. * @returns the max steps
  37693. */
  37694. getLockstepMaxSteps(): number;
  37695. /**
  37696. * Returns the time in ms between steps when using deterministic lock step.
  37697. * @returns time step in (ms)
  37698. */
  37699. getTimeStep(): number;
  37700. /**
  37701. * Force the mipmap generation for the given render target texture
  37702. * @param texture defines the render target texture to use
  37703. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37704. */
  37705. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37706. /** States */
  37707. /**
  37708. * Set various states to the webGL context
  37709. * @param culling defines backface culling state
  37710. * @param zOffset defines the value to apply to zOffset (0 by default)
  37711. * @param force defines if states must be applied even if cache is up to date
  37712. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37713. */
  37714. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37715. /**
  37716. * Set the z offset to apply to current rendering
  37717. * @param value defines the offset to apply
  37718. */
  37719. setZOffset(value: number): void;
  37720. /**
  37721. * Gets the current value of the zOffset
  37722. * @returns the current zOffset state
  37723. */
  37724. getZOffset(): number;
  37725. /**
  37726. * Enable or disable depth buffering
  37727. * @param enable defines the state to set
  37728. */
  37729. setDepthBuffer(enable: boolean): void;
  37730. /**
  37731. * Gets a boolean indicating if depth writing is enabled
  37732. * @returns the current depth writing state
  37733. */
  37734. getDepthWrite(): boolean;
  37735. /**
  37736. * Enable or disable depth writing
  37737. * @param enable defines the state to set
  37738. */
  37739. setDepthWrite(enable: boolean): void;
  37740. /**
  37741. * Gets a boolean indicating if stencil buffer is enabled
  37742. * @returns the current stencil buffer state
  37743. */
  37744. getStencilBuffer(): boolean;
  37745. /**
  37746. * Enable or disable the stencil buffer
  37747. * @param enable defines if the stencil buffer must be enabled or disabled
  37748. */
  37749. setStencilBuffer(enable: boolean): void;
  37750. /**
  37751. * Gets the current stencil mask
  37752. * @returns a number defining the new stencil mask to use
  37753. */
  37754. getStencilMask(): number;
  37755. /**
  37756. * Sets the current stencil mask
  37757. * @param mask defines the new stencil mask to use
  37758. */
  37759. setStencilMask(mask: number): void;
  37760. /**
  37761. * Gets the current stencil function
  37762. * @returns a number defining the stencil function to use
  37763. */
  37764. getStencilFunction(): number;
  37765. /**
  37766. * Gets the current stencil reference value
  37767. * @returns a number defining the stencil reference value to use
  37768. */
  37769. getStencilFunctionReference(): number;
  37770. /**
  37771. * Gets the current stencil mask
  37772. * @returns a number defining the stencil mask to use
  37773. */
  37774. getStencilFunctionMask(): number;
  37775. /**
  37776. * Sets the current stencil function
  37777. * @param stencilFunc defines the new stencil function to use
  37778. */
  37779. setStencilFunction(stencilFunc: number): void;
  37780. /**
  37781. * Sets the current stencil reference
  37782. * @param reference defines the new stencil reference to use
  37783. */
  37784. setStencilFunctionReference(reference: number): void;
  37785. /**
  37786. * Sets the current stencil mask
  37787. * @param mask defines the new stencil mask to use
  37788. */
  37789. setStencilFunctionMask(mask: number): void;
  37790. /**
  37791. * Gets the current stencil operation when stencil fails
  37792. * @returns a number defining stencil operation to use when stencil fails
  37793. */
  37794. getStencilOperationFail(): number;
  37795. /**
  37796. * Gets the current stencil operation when depth fails
  37797. * @returns a number defining stencil operation to use when depth fails
  37798. */
  37799. getStencilOperationDepthFail(): number;
  37800. /**
  37801. * Gets the current stencil operation when stencil passes
  37802. * @returns a number defining stencil operation to use when stencil passes
  37803. */
  37804. getStencilOperationPass(): number;
  37805. /**
  37806. * Sets the stencil operation to use when stencil fails
  37807. * @param operation defines the stencil operation to use when stencil fails
  37808. */
  37809. setStencilOperationFail(operation: number): void;
  37810. /**
  37811. * Sets the stencil operation to use when depth fails
  37812. * @param operation defines the stencil operation to use when depth fails
  37813. */
  37814. setStencilOperationDepthFail(operation: number): void;
  37815. /**
  37816. * Sets the stencil operation to use when stencil passes
  37817. * @param operation defines the stencil operation to use when stencil passes
  37818. */
  37819. setStencilOperationPass(operation: number): void;
  37820. /**
  37821. * Sets a boolean indicating if the dithering state is enabled or disabled
  37822. * @param value defines the dithering state
  37823. */
  37824. setDitheringState(value: boolean): void;
  37825. /**
  37826. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37827. * @param value defines the rasterizer state
  37828. */
  37829. setRasterizerState(value: boolean): void;
  37830. /**
  37831. * Gets the current depth function
  37832. * @returns a number defining the depth function
  37833. */
  37834. getDepthFunction(): Nullable<number>;
  37835. /**
  37836. * Sets the current depth function
  37837. * @param depthFunc defines the function to use
  37838. */
  37839. setDepthFunction(depthFunc: number): void;
  37840. /**
  37841. * Sets the current depth function to GREATER
  37842. */
  37843. setDepthFunctionToGreater(): void;
  37844. /**
  37845. * Sets the current depth function to GEQUAL
  37846. */
  37847. setDepthFunctionToGreaterOrEqual(): void;
  37848. /**
  37849. * Sets the current depth function to LESS
  37850. */
  37851. setDepthFunctionToLess(): void;
  37852. /**
  37853. * Sets the current depth function to LEQUAL
  37854. */
  37855. setDepthFunctionToLessOrEqual(): void;
  37856. private _cachedStencilBuffer;
  37857. private _cachedStencilFunction;
  37858. private _cachedStencilMask;
  37859. private _cachedStencilOperationPass;
  37860. private _cachedStencilOperationFail;
  37861. private _cachedStencilOperationDepthFail;
  37862. private _cachedStencilReference;
  37863. /**
  37864. * Caches the the state of the stencil buffer
  37865. */
  37866. cacheStencilState(): void;
  37867. /**
  37868. * Restores the state of the stencil buffer
  37869. */
  37870. restoreStencilState(): void;
  37871. /**
  37872. * Directly set the WebGL Viewport
  37873. * @param x defines the x coordinate of the viewport (in screen space)
  37874. * @param y defines the y coordinate of the viewport (in screen space)
  37875. * @param width defines the width of the viewport (in screen space)
  37876. * @param height defines the height of the viewport (in screen space)
  37877. * @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
  37878. */
  37879. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37880. /**
  37881. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37882. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37883. * @param y defines the y-coordinate of the corner of the clear rectangle
  37884. * @param width defines the width of the clear rectangle
  37885. * @param height defines the height of the clear rectangle
  37886. * @param clearColor defines the clear color
  37887. */
  37888. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37889. /**
  37890. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37891. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37892. * @param y defines the y-coordinate of the corner of the clear rectangle
  37893. * @param width defines the width of the clear rectangle
  37894. * @param height defines the height of the clear rectangle
  37895. */
  37896. enableScissor(x: number, y: number, width: number, height: number): void;
  37897. /**
  37898. * Disable previously set scissor test rectangle
  37899. */
  37900. disableScissor(): void;
  37901. protected _reportDrawCall(): void;
  37902. /**
  37903. * Initializes a webVR display and starts listening to display change events
  37904. * The onVRDisplayChangedObservable will be notified upon these changes
  37905. * @returns The onVRDisplayChangedObservable
  37906. */
  37907. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37908. /** @hidden */
  37909. _prepareVRComponent(): void;
  37910. /** @hidden */
  37911. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37912. /** @hidden */
  37913. _submitVRFrame(): void;
  37914. /**
  37915. * Call this function to leave webVR mode
  37916. * Will do nothing if webVR is not supported or if there is no webVR device
  37917. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37918. */
  37919. disableVR(): void;
  37920. /**
  37921. * Gets a boolean indicating that the system is in VR mode and is presenting
  37922. * @returns true if VR mode is engaged
  37923. */
  37924. isVRPresenting(): boolean;
  37925. /** @hidden */
  37926. _requestVRFrame(): void;
  37927. /** @hidden */
  37928. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37929. /**
  37930. * Gets the source code of the vertex shader associated with a specific webGL program
  37931. * @param program defines the program to use
  37932. * @returns a string containing the source code of the vertex shader associated with the program
  37933. */
  37934. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37935. /**
  37936. * Gets the source code of the fragment shader associated with a specific webGL program
  37937. * @param program defines the program to use
  37938. * @returns a string containing the source code of the fragment shader associated with the program
  37939. */
  37940. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37941. /**
  37942. * Sets a depth stencil texture from a render target to the according uniform.
  37943. * @param channel The texture channel
  37944. * @param uniform The uniform to set
  37945. * @param texture The render target texture containing the depth stencil texture to apply
  37946. */
  37947. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37948. /**
  37949. * Sets a texture to the webGL context from a postprocess
  37950. * @param channel defines the channel to use
  37951. * @param postProcess defines the source postprocess
  37952. */
  37953. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37954. /**
  37955. * Binds the output of the passed in post process to the texture channel specified
  37956. * @param channel The channel the texture should be bound to
  37957. * @param postProcess The post process which's output should be bound
  37958. */
  37959. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37960. protected _rebuildBuffers(): void;
  37961. /** @hidden */
  37962. _renderFrame(): void;
  37963. _renderLoop(): void;
  37964. /** @hidden */
  37965. _renderViews(): boolean;
  37966. /**
  37967. * Toggle full screen mode
  37968. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37969. */
  37970. switchFullscreen(requestPointerLock: boolean): void;
  37971. /**
  37972. * Enters full screen mode
  37973. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37974. */
  37975. enterFullscreen(requestPointerLock: boolean): void;
  37976. /**
  37977. * Exits full screen mode
  37978. */
  37979. exitFullscreen(): void;
  37980. /**
  37981. * Enters Pointerlock mode
  37982. */
  37983. enterPointerlock(): void;
  37984. /**
  37985. * Exits Pointerlock mode
  37986. */
  37987. exitPointerlock(): void;
  37988. /**
  37989. * Begin a new frame
  37990. */
  37991. beginFrame(): void;
  37992. /**
  37993. * Enf the current frame
  37994. */
  37995. endFrame(): void;
  37996. resize(): void;
  37997. /**
  37998. * Force a specific size of the canvas
  37999. * @param width defines the new canvas' width
  38000. * @param height defines the new canvas' height
  38001. * @returns true if the size was changed
  38002. */
  38003. setSize(width: number, height: number): boolean;
  38004. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38005. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38006. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38007. _releaseTexture(texture: InternalTexture): void;
  38008. /**
  38009. * @hidden
  38010. * Rescales a texture
  38011. * @param source input texutre
  38012. * @param destination destination texture
  38013. * @param scene scene to use to render the resize
  38014. * @param internalFormat format to use when resizing
  38015. * @param onComplete callback to be called when resize has completed
  38016. */
  38017. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38018. /**
  38019. * Gets the current framerate
  38020. * @returns a number representing the framerate
  38021. */
  38022. getFps(): number;
  38023. /**
  38024. * Gets the time spent between current and previous frame
  38025. * @returns a number representing the delta time in ms
  38026. */
  38027. getDeltaTime(): number;
  38028. private _measureFps;
  38029. /** @hidden */
  38030. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38031. /**
  38032. * Updates the sample count of a render target texture
  38033. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38034. * @param texture defines the texture to update
  38035. * @param samples defines the sample count to set
  38036. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38037. */
  38038. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38039. /**
  38040. * Updates a depth texture Comparison Mode and Function.
  38041. * If the comparison Function is equal to 0, the mode will be set to none.
  38042. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38043. * @param texture The texture to set the comparison function for
  38044. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38045. */
  38046. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38047. /**
  38048. * Creates a webGL buffer to use with instanciation
  38049. * @param capacity defines the size of the buffer
  38050. * @returns the webGL buffer
  38051. */
  38052. createInstancesBuffer(capacity: number): DataBuffer;
  38053. /**
  38054. * Delete a webGL buffer used with instanciation
  38055. * @param buffer defines the webGL buffer to delete
  38056. */
  38057. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38058. private _clientWaitAsync;
  38059. /** @hidden */
  38060. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38061. dispose(): void;
  38062. private _disableTouchAction;
  38063. /**
  38064. * Display the loading screen
  38065. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38066. */
  38067. displayLoadingUI(): void;
  38068. /**
  38069. * Hide the loading screen
  38070. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38071. */
  38072. hideLoadingUI(): void;
  38073. /**
  38074. * Gets the current loading screen object
  38075. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38076. */
  38077. get loadingScreen(): ILoadingScreen;
  38078. /**
  38079. * Sets the current loading screen object
  38080. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38081. */
  38082. set loadingScreen(loadingScreen: ILoadingScreen);
  38083. /**
  38084. * Sets the current loading screen text
  38085. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38086. */
  38087. set loadingUIText(text: string);
  38088. /**
  38089. * Sets the current loading screen background color
  38090. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38091. */
  38092. set loadingUIBackgroundColor(color: string);
  38093. /** Pointerlock and fullscreen */
  38094. /**
  38095. * Ask the browser to promote the current element to pointerlock mode
  38096. * @param element defines the DOM element to promote
  38097. */
  38098. static _RequestPointerlock(element: HTMLElement): void;
  38099. /**
  38100. * Asks the browser to exit pointerlock mode
  38101. */
  38102. static _ExitPointerlock(): void;
  38103. /**
  38104. * Ask the browser to promote the current element to fullscreen rendering mode
  38105. * @param element defines the DOM element to promote
  38106. */
  38107. static _RequestFullscreen(element: HTMLElement): void;
  38108. /**
  38109. * Asks the browser to exit fullscreen mode
  38110. */
  38111. static _ExitFullscreen(): void;
  38112. }
  38113. }
  38114. declare module BABYLON {
  38115. /**
  38116. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38117. * during the life time of the application.
  38118. */
  38119. export class EngineStore {
  38120. /** Gets the list of created engines */
  38121. static Instances: Engine[];
  38122. /** @hidden */
  38123. static _LastCreatedScene: Nullable<Scene>;
  38124. /**
  38125. * Gets the latest created engine
  38126. */
  38127. static get LastCreatedEngine(): Nullable<Engine>;
  38128. /**
  38129. * Gets the latest created scene
  38130. */
  38131. static get LastCreatedScene(): Nullable<Scene>;
  38132. /**
  38133. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38134. * @ignorenaming
  38135. */
  38136. static UseFallbackTexture: boolean;
  38137. /**
  38138. * Texture content used if a texture cannot loaded
  38139. * @ignorenaming
  38140. */
  38141. static FallbackTexture: string;
  38142. }
  38143. }
  38144. declare module BABYLON {
  38145. /**
  38146. * Helper class that provides a small promise polyfill
  38147. */
  38148. export class PromisePolyfill {
  38149. /**
  38150. * Static function used to check if the polyfill is required
  38151. * If this is the case then the function will inject the polyfill to window.Promise
  38152. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38153. */
  38154. static Apply(force?: boolean): void;
  38155. }
  38156. }
  38157. declare module BABYLON {
  38158. /**
  38159. * Interface for screenshot methods with describe argument called `size` as object with options
  38160. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38161. */
  38162. export interface IScreenshotSize {
  38163. /**
  38164. * number in pixels for canvas height
  38165. */
  38166. height?: number;
  38167. /**
  38168. * multiplier allowing render at a higher or lower resolution
  38169. * If value is defined then height and width will be ignored and taken from camera
  38170. */
  38171. precision?: number;
  38172. /**
  38173. * number in pixels for canvas width
  38174. */
  38175. width?: number;
  38176. }
  38177. }
  38178. declare module BABYLON {
  38179. interface IColor4Like {
  38180. r: float;
  38181. g: float;
  38182. b: float;
  38183. a: float;
  38184. }
  38185. /**
  38186. * Class containing a set of static utilities functions
  38187. */
  38188. export class Tools {
  38189. /**
  38190. * Gets or sets the base URL to use to load assets
  38191. */
  38192. static get BaseUrl(): string;
  38193. static set BaseUrl(value: string);
  38194. /**
  38195. * Enable/Disable Custom HTTP Request Headers globally.
  38196. * default = false
  38197. * @see CustomRequestHeaders
  38198. */
  38199. static UseCustomRequestHeaders: boolean;
  38200. /**
  38201. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38202. * i.e. when loading files, where the server/service expects an Authorization header
  38203. */
  38204. static CustomRequestHeaders: {
  38205. [key: string]: string;
  38206. };
  38207. /**
  38208. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38209. */
  38210. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38211. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38212. /**
  38213. * Default behaviour for cors in the application.
  38214. * It can be a string if the expected behavior is identical in the entire app.
  38215. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38216. */
  38217. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38218. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38219. /**
  38220. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38221. * @ignorenaming
  38222. */
  38223. static get UseFallbackTexture(): boolean;
  38224. static set UseFallbackTexture(value: boolean);
  38225. /**
  38226. * Use this object to register external classes like custom textures or material
  38227. * to allow the laoders to instantiate them
  38228. */
  38229. static get RegisteredExternalClasses(): {
  38230. [key: string]: Object;
  38231. };
  38232. static set RegisteredExternalClasses(classes: {
  38233. [key: string]: Object;
  38234. });
  38235. /**
  38236. * Texture content used if a texture cannot loaded
  38237. * @ignorenaming
  38238. */
  38239. static get fallbackTexture(): string;
  38240. static set fallbackTexture(value: string);
  38241. /**
  38242. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38243. * @param u defines the coordinate on X axis
  38244. * @param v defines the coordinate on Y axis
  38245. * @param width defines the width of the source data
  38246. * @param height defines the height of the source data
  38247. * @param pixels defines the source byte array
  38248. * @param color defines the output color
  38249. */
  38250. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38251. /**
  38252. * Interpolates between a and b via alpha
  38253. * @param a The lower value (returned when alpha = 0)
  38254. * @param b The upper value (returned when alpha = 1)
  38255. * @param alpha The interpolation-factor
  38256. * @return The mixed value
  38257. */
  38258. static Mix(a: number, b: number, alpha: number): number;
  38259. /**
  38260. * Tries to instantiate a new object from a given class name
  38261. * @param className defines the class name to instantiate
  38262. * @returns the new object or null if the system was not able to do the instantiation
  38263. */
  38264. static Instantiate(className: string): any;
  38265. /**
  38266. * Provides a slice function that will work even on IE
  38267. * @param data defines the array to slice
  38268. * @param start defines the start of the data (optional)
  38269. * @param end defines the end of the data (optional)
  38270. * @returns the new sliced array
  38271. */
  38272. static Slice<T>(data: T, start?: number, end?: number): T;
  38273. /**
  38274. * Polyfill for setImmediate
  38275. * @param action defines the action to execute after the current execution block
  38276. */
  38277. static SetImmediate(action: () => void): void;
  38278. /**
  38279. * Function indicating if a number is an exponent of 2
  38280. * @param value defines the value to test
  38281. * @returns true if the value is an exponent of 2
  38282. */
  38283. static IsExponentOfTwo(value: number): boolean;
  38284. private static _tmpFloatArray;
  38285. /**
  38286. * Returns the nearest 32-bit single precision float representation of a Number
  38287. * @param value A Number. If the parameter is of a different type, it will get converted
  38288. * to a number or to NaN if it cannot be converted
  38289. * @returns number
  38290. */
  38291. static FloatRound(value: number): number;
  38292. /**
  38293. * Extracts the filename from a path
  38294. * @param path defines the path to use
  38295. * @returns the filename
  38296. */
  38297. static GetFilename(path: string): string;
  38298. /**
  38299. * Extracts the "folder" part of a path (everything before the filename).
  38300. * @param uri The URI to extract the info from
  38301. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38302. * @returns The "folder" part of the path
  38303. */
  38304. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38305. /**
  38306. * Extracts text content from a DOM element hierarchy
  38307. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38308. */
  38309. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38310. /**
  38311. * Convert an angle in radians to degrees
  38312. * @param angle defines the angle to convert
  38313. * @returns the angle in degrees
  38314. */
  38315. static ToDegrees(angle: number): number;
  38316. /**
  38317. * Convert an angle in degrees to radians
  38318. * @param angle defines the angle to convert
  38319. * @returns the angle in radians
  38320. */
  38321. static ToRadians(angle: number): number;
  38322. /**
  38323. * Returns an array if obj is not an array
  38324. * @param obj defines the object to evaluate as an array
  38325. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38326. * @returns either obj directly if obj is an array or a new array containing obj
  38327. */
  38328. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38329. /**
  38330. * Gets the pointer prefix to use
  38331. * @param engine defines the engine we are finding the prefix for
  38332. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38333. */
  38334. static GetPointerPrefix(engine: Engine): string;
  38335. /**
  38336. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38337. * @param url define the url we are trying
  38338. * @param element define the dom element where to configure the cors policy
  38339. */
  38340. static SetCorsBehavior(url: string | string[], element: {
  38341. crossOrigin: string | null;
  38342. }): void;
  38343. /**
  38344. * Removes unwanted characters from an url
  38345. * @param url defines the url to clean
  38346. * @returns the cleaned url
  38347. */
  38348. static CleanUrl(url: string): string;
  38349. /**
  38350. * Gets or sets a function used to pre-process url before using them to load assets
  38351. */
  38352. static get PreprocessUrl(): (url: string) => string;
  38353. static set PreprocessUrl(processor: (url: string) => string);
  38354. /**
  38355. * Loads an image as an HTMLImageElement.
  38356. * @param input url string, ArrayBuffer, or Blob to load
  38357. * @param onLoad callback called when the image successfully loads
  38358. * @param onError callback called when the image fails to load
  38359. * @param offlineProvider offline provider for caching
  38360. * @param mimeType optional mime type
  38361. * @returns the HTMLImageElement of the loaded image
  38362. */
  38363. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38364. /**
  38365. * Loads a file from a url
  38366. * @param url url string, ArrayBuffer, or Blob to load
  38367. * @param onSuccess callback called when the file successfully loads
  38368. * @param onProgress callback called while file is loading (if the server supports this mode)
  38369. * @param offlineProvider defines the offline provider for caching
  38370. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38371. * @param onError callback called when the file fails to load
  38372. * @returns a file request object
  38373. */
  38374. 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;
  38375. /**
  38376. * Loads a file from a url
  38377. * @param url the file url to load
  38378. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38379. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38380. */
  38381. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38382. /**
  38383. * Load a script (identified by an url). When the url returns, the
  38384. * content of this file is added into a new script element, attached to the DOM (body element)
  38385. * @param scriptUrl defines the url of the script to laod
  38386. * @param onSuccess defines the callback called when the script is loaded
  38387. * @param onError defines the callback to call if an error occurs
  38388. * @param scriptId defines the id of the script element
  38389. */
  38390. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38391. /**
  38392. * Load an asynchronous script (identified by an url). When the url returns, the
  38393. * content of this file is added into a new script element, attached to the DOM (body element)
  38394. * @param scriptUrl defines the url of the script to laod
  38395. * @param scriptId defines the id of the script element
  38396. * @returns a promise request object
  38397. */
  38398. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38399. /**
  38400. * Loads a file from a blob
  38401. * @param fileToLoad defines the blob to use
  38402. * @param callback defines the callback to call when data is loaded
  38403. * @param progressCallback defines the callback to call during loading process
  38404. * @returns a file request object
  38405. */
  38406. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38407. /**
  38408. * Reads a file from a File object
  38409. * @param file defines the file to load
  38410. * @param onSuccess defines the callback to call when data is loaded
  38411. * @param onProgress defines the callback to call during loading process
  38412. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38413. * @param onError defines the callback to call when an error occurs
  38414. * @returns a file request object
  38415. */
  38416. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38417. /**
  38418. * Creates a data url from a given string content
  38419. * @param content defines the content to convert
  38420. * @returns the new data url link
  38421. */
  38422. static FileAsURL(content: string): string;
  38423. /**
  38424. * Format the given number to a specific decimal format
  38425. * @param value defines the number to format
  38426. * @param decimals defines the number of decimals to use
  38427. * @returns the formatted string
  38428. */
  38429. static Format(value: number, decimals?: number): string;
  38430. /**
  38431. * Tries to copy an object by duplicating every property
  38432. * @param source defines the source object
  38433. * @param destination defines the target object
  38434. * @param doNotCopyList defines a list of properties to avoid
  38435. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38436. */
  38437. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38438. /**
  38439. * Gets a boolean indicating if the given object has no own property
  38440. * @param obj defines the object to test
  38441. * @returns true if object has no own property
  38442. */
  38443. static IsEmpty(obj: any): boolean;
  38444. /**
  38445. * Function used to register events at window level
  38446. * @param windowElement defines the Window object to use
  38447. * @param events defines the events to register
  38448. */
  38449. static RegisterTopRootEvents(windowElement: Window, events: {
  38450. name: string;
  38451. handler: Nullable<(e: FocusEvent) => any>;
  38452. }[]): void;
  38453. /**
  38454. * Function used to unregister events from window level
  38455. * @param windowElement defines the Window object to use
  38456. * @param events defines the events to unregister
  38457. */
  38458. static UnregisterTopRootEvents(windowElement: Window, events: {
  38459. name: string;
  38460. handler: Nullable<(e: FocusEvent) => any>;
  38461. }[]): void;
  38462. /**
  38463. * @ignore
  38464. */
  38465. static _ScreenshotCanvas: HTMLCanvasElement;
  38466. /**
  38467. * Dumps the current bound framebuffer
  38468. * @param width defines the rendering width
  38469. * @param height defines the rendering height
  38470. * @param engine defines the hosting engine
  38471. * @param successCallback defines the callback triggered once the data are available
  38472. * @param mimeType defines the mime type of the result
  38473. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38474. */
  38475. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38476. /**
  38477. * Converts the canvas data to blob.
  38478. * This acts as a polyfill for browsers not supporting the to blob function.
  38479. * @param canvas Defines the canvas to extract the data from
  38480. * @param successCallback Defines the callback triggered once the data are available
  38481. * @param mimeType Defines the mime type of the result
  38482. */
  38483. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38484. /**
  38485. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38486. * @param successCallback defines the callback triggered once the data are available
  38487. * @param mimeType defines the mime type of the result
  38488. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38489. */
  38490. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38491. /**
  38492. * Downloads a blob in the browser
  38493. * @param blob defines the blob to download
  38494. * @param fileName defines the name of the downloaded file
  38495. */
  38496. static Download(blob: Blob, fileName: string): void;
  38497. /**
  38498. * Captures a screenshot of the current rendering
  38499. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38500. * @param engine defines the rendering engine
  38501. * @param camera defines the source camera
  38502. * @param size This parameter can be set to a single number or to an object with the
  38503. * following (optional) properties: precision, width, height. If a single number is passed,
  38504. * it will be used for both width and height. If an object is passed, the screenshot size
  38505. * will be derived from the parameters. The precision property is a multiplier allowing
  38506. * rendering at a higher or lower resolution
  38507. * @param successCallback defines the callback receives a single parameter which contains the
  38508. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38509. * src parameter of an <img> to display it
  38510. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38511. * Check your browser for supported MIME types
  38512. */
  38513. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38514. /**
  38515. * Captures a screenshot of the current rendering
  38516. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38517. * @param engine defines the rendering engine
  38518. * @param camera defines the source camera
  38519. * @param size This parameter can be set to a single number or to an object with the
  38520. * following (optional) properties: precision, width, height. If a single number is passed,
  38521. * it will be used for both width and height. If an object is passed, the screenshot size
  38522. * will be derived from the parameters. The precision property is a multiplier allowing
  38523. * rendering at a higher or lower resolution
  38524. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38525. * Check your browser for supported MIME types
  38526. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38527. * to the src parameter of an <img> to display it
  38528. */
  38529. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38530. /**
  38531. * Generates an image screenshot from the specified camera.
  38532. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38533. * @param engine The engine to use for rendering
  38534. * @param camera The camera to use for rendering
  38535. * @param size This parameter can be set to a single number or to an object with the
  38536. * following (optional) properties: precision, width, height. If a single number is passed,
  38537. * it will be used for both width and height. If an object is passed, the screenshot size
  38538. * will be derived from the parameters. The precision property is a multiplier allowing
  38539. * rendering at a higher or lower resolution
  38540. * @param successCallback The callback receives a single parameter which contains the
  38541. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38542. * src parameter of an <img> to display it
  38543. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38544. * Check your browser for supported MIME types
  38545. * @param samples Texture samples (default: 1)
  38546. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38547. * @param fileName A name for for the downloaded file.
  38548. */
  38549. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38550. /**
  38551. * Generates an image screenshot from the specified camera.
  38552. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38553. * @param engine The engine to use for rendering
  38554. * @param camera The camera to use for rendering
  38555. * @param size This parameter can be set to a single number or to an object with the
  38556. * following (optional) properties: precision, width, height. If a single number is passed,
  38557. * it will be used for both width and height. If an object is passed, the screenshot size
  38558. * will be derived from the parameters. The precision property is a multiplier allowing
  38559. * rendering at a higher or lower resolution
  38560. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38561. * Check your browser for supported MIME types
  38562. * @param samples Texture samples (default: 1)
  38563. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38564. * @param fileName A name for for the downloaded file.
  38565. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38566. * to the src parameter of an <img> to display it
  38567. */
  38568. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38569. /**
  38570. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38571. * Be aware Math.random() could cause collisions, but:
  38572. * "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"
  38573. * @returns a pseudo random id
  38574. */
  38575. static RandomId(): string;
  38576. /**
  38577. * Test if the given uri is a base64 string
  38578. * @param uri The uri to test
  38579. * @return True if the uri is a base64 string or false otherwise
  38580. */
  38581. static IsBase64(uri: string): boolean;
  38582. /**
  38583. * Decode the given base64 uri.
  38584. * @param uri The uri to decode
  38585. * @return The decoded base64 data.
  38586. */
  38587. static DecodeBase64(uri: string): ArrayBuffer;
  38588. /**
  38589. * Gets the absolute url.
  38590. * @param url the input url
  38591. * @return the absolute url
  38592. */
  38593. static GetAbsoluteUrl(url: string): string;
  38594. /**
  38595. * No log
  38596. */
  38597. static readonly NoneLogLevel: number;
  38598. /**
  38599. * Only message logs
  38600. */
  38601. static readonly MessageLogLevel: number;
  38602. /**
  38603. * Only warning logs
  38604. */
  38605. static readonly WarningLogLevel: number;
  38606. /**
  38607. * Only error logs
  38608. */
  38609. static readonly ErrorLogLevel: number;
  38610. /**
  38611. * All logs
  38612. */
  38613. static readonly AllLogLevel: number;
  38614. /**
  38615. * Gets a value indicating the number of loading errors
  38616. * @ignorenaming
  38617. */
  38618. static get errorsCount(): number;
  38619. /**
  38620. * Callback called when a new log is added
  38621. */
  38622. static OnNewCacheEntry: (entry: string) => void;
  38623. /**
  38624. * Log a message to the console
  38625. * @param message defines the message to log
  38626. */
  38627. static Log(message: string): void;
  38628. /**
  38629. * Write a warning message to the console
  38630. * @param message defines the message to log
  38631. */
  38632. static Warn(message: string): void;
  38633. /**
  38634. * Write an error message to the console
  38635. * @param message defines the message to log
  38636. */
  38637. static Error(message: string): void;
  38638. /**
  38639. * Gets current log cache (list of logs)
  38640. */
  38641. static get LogCache(): string;
  38642. /**
  38643. * Clears the log cache
  38644. */
  38645. static ClearLogCache(): void;
  38646. /**
  38647. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38648. */
  38649. static set LogLevels(level: number);
  38650. /**
  38651. * Checks if the window object exists
  38652. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38653. */
  38654. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38655. /**
  38656. * No performance log
  38657. */
  38658. static readonly PerformanceNoneLogLevel: number;
  38659. /**
  38660. * Use user marks to log performance
  38661. */
  38662. static readonly PerformanceUserMarkLogLevel: number;
  38663. /**
  38664. * Log performance to the console
  38665. */
  38666. static readonly PerformanceConsoleLogLevel: number;
  38667. private static _performance;
  38668. /**
  38669. * Sets the current performance log level
  38670. */
  38671. static set PerformanceLogLevel(level: number);
  38672. private static _StartPerformanceCounterDisabled;
  38673. private static _EndPerformanceCounterDisabled;
  38674. private static _StartUserMark;
  38675. private static _EndUserMark;
  38676. private static _StartPerformanceConsole;
  38677. private static _EndPerformanceConsole;
  38678. /**
  38679. * Starts a performance counter
  38680. */
  38681. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38682. /**
  38683. * Ends a specific performance coutner
  38684. */
  38685. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38686. /**
  38687. * Gets either window.performance.now() if supported or Date.now() else
  38688. */
  38689. static get Now(): number;
  38690. /**
  38691. * This method will return the name of the class used to create the instance of the given object.
  38692. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38693. * @param object the object to get the class name from
  38694. * @param isType defines if the object is actually a type
  38695. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38696. */
  38697. static GetClassName(object: any, isType?: boolean): string;
  38698. /**
  38699. * Gets the first element of an array satisfying a given predicate
  38700. * @param array defines the array to browse
  38701. * @param predicate defines the predicate to use
  38702. * @returns null if not found or the element
  38703. */
  38704. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38705. /**
  38706. * This method will return the name of the full name of the class, including its owning module (if any).
  38707. * 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).
  38708. * @param object the object to get the class name from
  38709. * @param isType defines if the object is actually a type
  38710. * @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.
  38711. * @ignorenaming
  38712. */
  38713. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38714. /**
  38715. * Returns a promise that resolves after the given amount of time.
  38716. * @param delay Number of milliseconds to delay
  38717. * @returns Promise that resolves after the given amount of time
  38718. */
  38719. static DelayAsync(delay: number): Promise<void>;
  38720. /**
  38721. * Utility function to detect if the current user agent is Safari
  38722. * @returns whether or not the current user agent is safari
  38723. */
  38724. static IsSafari(): boolean;
  38725. }
  38726. /**
  38727. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38728. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38729. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38730. * @param name The name of the class, case should be preserved
  38731. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38732. */
  38733. export function className(name: string, module?: string): (target: Object) => void;
  38734. /**
  38735. * An implementation of a loop for asynchronous functions.
  38736. */
  38737. export class AsyncLoop {
  38738. /**
  38739. * Defines the number of iterations for the loop
  38740. */
  38741. iterations: number;
  38742. /**
  38743. * Defines the current index of the loop.
  38744. */
  38745. index: number;
  38746. private _done;
  38747. private _fn;
  38748. private _successCallback;
  38749. /**
  38750. * Constructor.
  38751. * @param iterations the number of iterations.
  38752. * @param func the function to run each iteration
  38753. * @param successCallback the callback that will be called upon succesful execution
  38754. * @param offset starting offset.
  38755. */
  38756. constructor(
  38757. /**
  38758. * Defines the number of iterations for the loop
  38759. */
  38760. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38761. /**
  38762. * Execute the next iteration. Must be called after the last iteration was finished.
  38763. */
  38764. executeNext(): void;
  38765. /**
  38766. * Break the loop and run the success callback.
  38767. */
  38768. breakLoop(): void;
  38769. /**
  38770. * Create and run an async loop.
  38771. * @param iterations the number of iterations.
  38772. * @param fn the function to run each iteration
  38773. * @param successCallback the callback that will be called upon succesful execution
  38774. * @param offset starting offset.
  38775. * @returns the created async loop object
  38776. */
  38777. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38778. /**
  38779. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38780. * @param iterations total number of iterations
  38781. * @param syncedIterations number of synchronous iterations in each async iteration.
  38782. * @param fn the function to call each iteration.
  38783. * @param callback a success call back that will be called when iterating stops.
  38784. * @param breakFunction a break condition (optional)
  38785. * @param timeout timeout settings for the setTimeout function. default - 0.
  38786. * @returns the created async loop object
  38787. */
  38788. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38794. * The underlying implementation relies on an associative array to ensure the best performances.
  38795. * The value can be anything including 'null' but except 'undefined'
  38796. */
  38797. export class StringDictionary<T> {
  38798. /**
  38799. * This will clear this dictionary and copy the content from the 'source' one.
  38800. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38801. * @param source the dictionary to take the content from and copy to this dictionary
  38802. */
  38803. copyFrom(source: StringDictionary<T>): void;
  38804. /**
  38805. * Get a value based from its key
  38806. * @param key the given key to get the matching value from
  38807. * @return the value if found, otherwise undefined is returned
  38808. */
  38809. get(key: string): T | undefined;
  38810. /**
  38811. * Get a value from its key or add it if it doesn't exist.
  38812. * This method will ensure you that a given key/data will be present in the dictionary.
  38813. * @param key the given key to get the matching value from
  38814. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38815. * The factory will only be invoked if there's no data for the given key.
  38816. * @return the value corresponding to the key.
  38817. */
  38818. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38819. /**
  38820. * Get a value from its key if present in the dictionary otherwise add it
  38821. * @param key the key to get the value from
  38822. * @param val if there's no such key/value pair in the dictionary add it with this value
  38823. * @return the value corresponding to the key
  38824. */
  38825. getOrAdd(key: string, val: T): T;
  38826. /**
  38827. * Check if there's a given key in the dictionary
  38828. * @param key the key to check for
  38829. * @return true if the key is present, false otherwise
  38830. */
  38831. contains(key: string): boolean;
  38832. /**
  38833. * Add a new key and its corresponding value
  38834. * @param key the key to add
  38835. * @param value the value corresponding to the key
  38836. * @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
  38837. */
  38838. add(key: string, value: T): boolean;
  38839. /**
  38840. * Update a specific value associated to a key
  38841. * @param key defines the key to use
  38842. * @param value defines the value to store
  38843. * @returns true if the value was updated (or false if the key was not found)
  38844. */
  38845. set(key: string, value: T): boolean;
  38846. /**
  38847. * Get the element of the given key and remove it from the dictionary
  38848. * @param key defines the key to search
  38849. * @returns the value associated with the key or null if not found
  38850. */
  38851. getAndRemove(key: string): Nullable<T>;
  38852. /**
  38853. * Remove a key/value from the dictionary.
  38854. * @param key the key to remove
  38855. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38856. */
  38857. remove(key: string): boolean;
  38858. /**
  38859. * Clear the whole content of the dictionary
  38860. */
  38861. clear(): void;
  38862. /**
  38863. * Gets the current count
  38864. */
  38865. get count(): number;
  38866. /**
  38867. * Execute a callback on each key/val of the dictionary.
  38868. * Note that you can remove any element in this dictionary in the callback implementation
  38869. * @param callback the callback to execute on a given key/value pair
  38870. */
  38871. forEach(callback: (key: string, val: T) => void): void;
  38872. /**
  38873. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38874. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38875. * Note that you can remove any element in this dictionary in the callback implementation
  38876. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38877. * @returns the first item
  38878. */
  38879. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38880. private _count;
  38881. private _data;
  38882. }
  38883. }
  38884. declare module BABYLON {
  38885. /** @hidden */
  38886. export interface ICollisionCoordinator {
  38887. createCollider(): Collider;
  38888. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38889. init(scene: Scene): void;
  38890. }
  38891. /** @hidden */
  38892. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38893. private _scene;
  38894. private _scaledPosition;
  38895. private _scaledVelocity;
  38896. private _finalPosition;
  38897. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38898. createCollider(): Collider;
  38899. init(scene: Scene): void;
  38900. private _collideWithWorld;
  38901. }
  38902. }
  38903. declare module BABYLON {
  38904. /**
  38905. * Class used to manage all inputs for the scene.
  38906. */
  38907. export class InputManager {
  38908. /** The distance in pixel that you have to move to prevent some events */
  38909. static DragMovementThreshold: number;
  38910. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38911. static LongPressDelay: number;
  38912. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38913. static DoubleClickDelay: number;
  38914. /** If you need to check double click without raising a single click at first click, enable this flag */
  38915. static ExclusiveDoubleClickMode: boolean;
  38916. /** 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. */
  38917. private _alreadyAttached;
  38918. private _wheelEventName;
  38919. private _onPointerMove;
  38920. private _onPointerDown;
  38921. private _onPointerUp;
  38922. private _initClickEvent;
  38923. private _initActionManager;
  38924. private _delayedSimpleClick;
  38925. private _delayedSimpleClickTimeout;
  38926. private _previousDelayedSimpleClickTimeout;
  38927. private _meshPickProceed;
  38928. private _previousButtonPressed;
  38929. private _currentPickResult;
  38930. private _previousPickResult;
  38931. private _totalPointersPressed;
  38932. private _doubleClickOccured;
  38933. private _pointerOverMesh;
  38934. private _pickedDownMesh;
  38935. private _pickedUpMesh;
  38936. private _pointerX;
  38937. private _pointerY;
  38938. private _unTranslatedPointerX;
  38939. private _unTranslatedPointerY;
  38940. private _startingPointerPosition;
  38941. private _previousStartingPointerPosition;
  38942. private _startingPointerTime;
  38943. private _previousStartingPointerTime;
  38944. private _pointerCaptures;
  38945. private _meshUnderPointerId;
  38946. private _onKeyDown;
  38947. private _onKeyUp;
  38948. private _onCanvasFocusObserver;
  38949. private _onCanvasBlurObserver;
  38950. private _scene;
  38951. /**
  38952. * Creates a new InputManager
  38953. * @param scene defines the hosting scene
  38954. */
  38955. constructor(scene: Scene);
  38956. /**
  38957. * Gets the mesh that is currently under the pointer
  38958. */
  38959. get meshUnderPointer(): Nullable<AbstractMesh>;
  38960. /**
  38961. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  38962. * @param pointerId the pointer id to use
  38963. * @returns The mesh under this pointer id or null if not found
  38964. */
  38965. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  38966. /**
  38967. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38968. */
  38969. get unTranslatedPointer(): Vector2;
  38970. /**
  38971. * Gets or sets the current on-screen X position of the pointer
  38972. */
  38973. get pointerX(): number;
  38974. set pointerX(value: number);
  38975. /**
  38976. * Gets or sets the current on-screen Y position of the pointer
  38977. */
  38978. get pointerY(): number;
  38979. set pointerY(value: number);
  38980. private _updatePointerPosition;
  38981. private _processPointerMove;
  38982. private _setRayOnPointerInfo;
  38983. private _checkPrePointerObservable;
  38984. /**
  38985. * Use this method to simulate a pointer move on a mesh
  38986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38989. */
  38990. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38991. /**
  38992. * Use this method to simulate a pointer down on a mesh
  38993. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38994. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38995. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38996. */
  38997. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38998. private _processPointerDown;
  38999. /** @hidden */
  39000. _isPointerSwiping(): boolean;
  39001. /**
  39002. * Use this method to simulate a pointer up on a mesh
  39003. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39004. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39005. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39006. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39007. */
  39008. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39009. private _processPointerUp;
  39010. /**
  39011. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39012. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39013. * @returns true if the pointer was captured
  39014. */
  39015. isPointerCaptured(pointerId?: number): boolean;
  39016. /**
  39017. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39018. * @param attachUp defines if you want to attach events to pointerup
  39019. * @param attachDown defines if you want to attach events to pointerdown
  39020. * @param attachMove defines if you want to attach events to pointermove
  39021. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39022. */
  39023. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39024. /**
  39025. * Detaches all event handlers
  39026. */
  39027. detachControl(): void;
  39028. /**
  39029. * Force the value of meshUnderPointer
  39030. * @param mesh defines the mesh to use
  39031. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39032. */
  39033. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39034. /**
  39035. * Gets the mesh under the pointer
  39036. * @returns a Mesh or null if no mesh is under the pointer
  39037. */
  39038. getPointerOverMesh(): Nullable<AbstractMesh>;
  39039. }
  39040. }
  39041. declare module BABYLON {
  39042. /**
  39043. * This class defines the direct association between an animation and a target
  39044. */
  39045. export class TargetedAnimation {
  39046. /**
  39047. * Animation to perform
  39048. */
  39049. animation: Animation;
  39050. /**
  39051. * Target to animate
  39052. */
  39053. target: any;
  39054. /**
  39055. * Returns the string "TargetedAnimation"
  39056. * @returns "TargetedAnimation"
  39057. */
  39058. getClassName(): string;
  39059. /**
  39060. * Serialize the object
  39061. * @returns the JSON object representing the current entity
  39062. */
  39063. serialize(): any;
  39064. }
  39065. /**
  39066. * Use this class to create coordinated animations on multiple targets
  39067. */
  39068. export class AnimationGroup implements IDisposable {
  39069. /** The name of the animation group */
  39070. name: string;
  39071. private _scene;
  39072. private _targetedAnimations;
  39073. private _animatables;
  39074. private _from;
  39075. private _to;
  39076. private _isStarted;
  39077. private _isPaused;
  39078. private _speedRatio;
  39079. private _loopAnimation;
  39080. private _isAdditive;
  39081. /**
  39082. * Gets or sets the unique id of the node
  39083. */
  39084. uniqueId: number;
  39085. /**
  39086. * This observable will notify when one animation have ended
  39087. */
  39088. onAnimationEndObservable: Observable<TargetedAnimation>;
  39089. /**
  39090. * Observer raised when one animation loops
  39091. */
  39092. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39093. /**
  39094. * Observer raised when all animations have looped
  39095. */
  39096. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39097. /**
  39098. * This observable will notify when all animations have ended.
  39099. */
  39100. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39101. /**
  39102. * This observable will notify when all animations have paused.
  39103. */
  39104. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39105. /**
  39106. * This observable will notify when all animations are playing.
  39107. */
  39108. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39109. /**
  39110. * Gets the first frame
  39111. */
  39112. get from(): number;
  39113. /**
  39114. * Gets the last frame
  39115. */
  39116. get to(): number;
  39117. /**
  39118. * Define if the animations are started
  39119. */
  39120. get isStarted(): boolean;
  39121. /**
  39122. * Gets a value indicating that the current group is playing
  39123. */
  39124. get isPlaying(): boolean;
  39125. /**
  39126. * Gets or sets the speed ratio to use for all animations
  39127. */
  39128. get speedRatio(): number;
  39129. /**
  39130. * Gets or sets the speed ratio to use for all animations
  39131. */
  39132. set speedRatio(value: number);
  39133. /**
  39134. * Gets or sets if all animations should loop or not
  39135. */
  39136. get loopAnimation(): boolean;
  39137. set loopAnimation(value: boolean);
  39138. /**
  39139. * Gets or sets if all animations should be evaluated additively
  39140. */
  39141. get isAdditive(): boolean;
  39142. set isAdditive(value: boolean);
  39143. /**
  39144. * Gets the targeted animations for this animation group
  39145. */
  39146. get targetedAnimations(): Array<TargetedAnimation>;
  39147. /**
  39148. * returning the list of animatables controlled by this animation group.
  39149. */
  39150. get animatables(): Array<Animatable>;
  39151. /**
  39152. * Gets the list of target animations
  39153. */
  39154. get children(): TargetedAnimation[];
  39155. /**
  39156. * Instantiates a new Animation Group.
  39157. * This helps managing several animations at once.
  39158. * @see https://doc.babylonjs.com/how_to/group
  39159. * @param name Defines the name of the group
  39160. * @param scene Defines the scene the group belongs to
  39161. */
  39162. constructor(
  39163. /** The name of the animation group */
  39164. name: string, scene?: Nullable<Scene>);
  39165. /**
  39166. * Add an animation (with its target) in the group
  39167. * @param animation defines the animation we want to add
  39168. * @param target defines the target of the animation
  39169. * @returns the TargetedAnimation object
  39170. */
  39171. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39172. /**
  39173. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39174. * It can add constant keys at begin or end
  39175. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39176. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39177. * @returns the animation group
  39178. */
  39179. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39180. private _animationLoopCount;
  39181. private _animationLoopFlags;
  39182. private _processLoop;
  39183. /**
  39184. * Start all animations on given targets
  39185. * @param loop defines if animations must loop
  39186. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39187. * @param from defines the from key (optional)
  39188. * @param to defines the to key (optional)
  39189. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39190. * @returns the current animation group
  39191. */
  39192. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39193. /**
  39194. * Pause all animations
  39195. * @returns the animation group
  39196. */
  39197. pause(): AnimationGroup;
  39198. /**
  39199. * Play all animations to initial state
  39200. * This function will start() the animations if they were not started or will restart() them if they were paused
  39201. * @param loop defines if animations must loop
  39202. * @returns the animation group
  39203. */
  39204. play(loop?: boolean): AnimationGroup;
  39205. /**
  39206. * Reset all animations to initial state
  39207. * @returns the animation group
  39208. */
  39209. reset(): AnimationGroup;
  39210. /**
  39211. * Restart animations from key 0
  39212. * @returns the animation group
  39213. */
  39214. restart(): AnimationGroup;
  39215. /**
  39216. * Stop all animations
  39217. * @returns the animation group
  39218. */
  39219. stop(): AnimationGroup;
  39220. /**
  39221. * Set animation weight for all animatables
  39222. * @param weight defines the weight to use
  39223. * @return the animationGroup
  39224. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39225. */
  39226. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39227. /**
  39228. * Synchronize and normalize all animatables with a source animatable
  39229. * @param root defines the root animatable to synchronize with
  39230. * @return the animationGroup
  39231. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39232. */
  39233. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39234. /**
  39235. * Goes to a specific frame in this animation group
  39236. * @param frame the frame number to go to
  39237. * @return the animationGroup
  39238. */
  39239. goToFrame(frame: number): AnimationGroup;
  39240. /**
  39241. * Dispose all associated resources
  39242. */
  39243. dispose(): void;
  39244. private _checkAnimationGroupEnded;
  39245. /**
  39246. * Clone the current animation group and returns a copy
  39247. * @param newName defines the name of the new group
  39248. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39249. * @returns the new aniamtion group
  39250. */
  39251. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39252. /**
  39253. * Serializes the animationGroup to an object
  39254. * @returns Serialized object
  39255. */
  39256. serialize(): any;
  39257. /**
  39258. * Returns a new AnimationGroup object parsed from the source provided.
  39259. * @param parsedAnimationGroup defines the source
  39260. * @param scene defines the scene that will receive the animationGroup
  39261. * @returns a new AnimationGroup
  39262. */
  39263. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39264. /**
  39265. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39266. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39267. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39268. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39269. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39270. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39271. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39272. */
  39273. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39274. /**
  39275. * Returns the string "AnimationGroup"
  39276. * @returns "AnimationGroup"
  39277. */
  39278. getClassName(): string;
  39279. /**
  39280. * Creates a detailled string about the object
  39281. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39282. * @returns a string representing the object
  39283. */
  39284. toString(fullDetails?: boolean): string;
  39285. }
  39286. }
  39287. declare module BABYLON {
  39288. /**
  39289. * Define an interface for all classes that will hold resources
  39290. */
  39291. export interface IDisposable {
  39292. /**
  39293. * Releases all held resources
  39294. */
  39295. dispose(): void;
  39296. }
  39297. /** Interface defining initialization parameters for Scene class */
  39298. export interface SceneOptions {
  39299. /**
  39300. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39301. * It will improve performance when the number of geometries becomes important.
  39302. */
  39303. useGeometryUniqueIdsMap?: boolean;
  39304. /**
  39305. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39306. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39307. */
  39308. useMaterialMeshMap?: boolean;
  39309. /**
  39310. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39311. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39312. */
  39313. useClonedMeshMap?: boolean;
  39314. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39315. virtual?: boolean;
  39316. }
  39317. /**
  39318. * Represents a scene to be rendered by the engine.
  39319. * @see https://doc.babylonjs.com/features/scene
  39320. */
  39321. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39322. /** The fog is deactivated */
  39323. static readonly FOGMODE_NONE: number;
  39324. /** The fog density is following an exponential function */
  39325. static readonly FOGMODE_EXP: number;
  39326. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39327. static readonly FOGMODE_EXP2: number;
  39328. /** The fog density is following a linear function. */
  39329. static readonly FOGMODE_LINEAR: number;
  39330. /**
  39331. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39332. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39333. */
  39334. static MinDeltaTime: number;
  39335. /**
  39336. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39337. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39338. */
  39339. static MaxDeltaTime: number;
  39340. /**
  39341. * Factory used to create the default material.
  39342. * @param name The name of the material to create
  39343. * @param scene The scene to create the material for
  39344. * @returns The default material
  39345. */
  39346. static DefaultMaterialFactory(scene: Scene): Material;
  39347. /**
  39348. * Factory used to create the a collision coordinator.
  39349. * @returns The collision coordinator
  39350. */
  39351. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39352. /** @hidden */
  39353. _inputManager: InputManager;
  39354. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39355. cameraToUseForPointers: Nullable<Camera>;
  39356. /** @hidden */
  39357. readonly _isScene: boolean;
  39358. /** @hidden */
  39359. _blockEntityCollection: boolean;
  39360. /**
  39361. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39362. */
  39363. autoClear: boolean;
  39364. /**
  39365. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39366. */
  39367. autoClearDepthAndStencil: boolean;
  39368. /**
  39369. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39370. */
  39371. clearColor: Color4;
  39372. /**
  39373. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39374. */
  39375. ambientColor: Color3;
  39376. /**
  39377. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39378. * It should only be one of the following (if not the default embedded one):
  39379. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39380. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39381. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39382. * The material properties need to be setup according to the type of texture in use.
  39383. */
  39384. environmentBRDFTexture: BaseTexture;
  39385. /**
  39386. * Texture used in all pbr material as the reflection texture.
  39387. * As in the majority of the scene they are the same (exception for multi room and so on),
  39388. * this is easier to reference from here than from all the materials.
  39389. */
  39390. get environmentTexture(): Nullable<BaseTexture>;
  39391. /**
  39392. * Texture used in all pbr material as the reflection texture.
  39393. * As in the majority of the scene they are the same (exception for multi room and so on),
  39394. * this is easier to set here than in all the materials.
  39395. */
  39396. set environmentTexture(value: Nullable<BaseTexture>);
  39397. /** @hidden */
  39398. protected _environmentIntensity: number;
  39399. /**
  39400. * Intensity of the environment in all pbr material.
  39401. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39402. * As in the majority of the scene they are the same (exception for multi room and so on),
  39403. * this is easier to reference from here than from all the materials.
  39404. */
  39405. get environmentIntensity(): number;
  39406. /**
  39407. * Intensity of the environment in all pbr material.
  39408. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39409. * As in the majority of the scene they are the same (exception for multi room and so on),
  39410. * this is easier to set here than in all the materials.
  39411. */
  39412. set environmentIntensity(value: number);
  39413. /** @hidden */
  39414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39415. /**
  39416. * Default image processing configuration used either in the rendering
  39417. * Forward main pass or through the imageProcessingPostProcess if present.
  39418. * As in the majority of the scene they are the same (exception for multi camera),
  39419. * this is easier to reference from here than from all the materials and post process.
  39420. *
  39421. * No setter as we it is a shared configuration, you can set the values instead.
  39422. */
  39423. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39424. private _forceWireframe;
  39425. /**
  39426. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39427. */
  39428. set forceWireframe(value: boolean);
  39429. get forceWireframe(): boolean;
  39430. private _skipFrustumClipping;
  39431. /**
  39432. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39433. */
  39434. set skipFrustumClipping(value: boolean);
  39435. get skipFrustumClipping(): boolean;
  39436. private _forcePointsCloud;
  39437. /**
  39438. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39439. */
  39440. set forcePointsCloud(value: boolean);
  39441. get forcePointsCloud(): boolean;
  39442. /**
  39443. * Gets or sets the active clipplane 1
  39444. */
  39445. clipPlane: Nullable<Plane>;
  39446. /**
  39447. * Gets or sets the active clipplane 2
  39448. */
  39449. clipPlane2: Nullable<Plane>;
  39450. /**
  39451. * Gets or sets the active clipplane 3
  39452. */
  39453. clipPlane3: Nullable<Plane>;
  39454. /**
  39455. * Gets or sets the active clipplane 4
  39456. */
  39457. clipPlane4: Nullable<Plane>;
  39458. /**
  39459. * Gets or sets the active clipplane 5
  39460. */
  39461. clipPlane5: Nullable<Plane>;
  39462. /**
  39463. * Gets or sets the active clipplane 6
  39464. */
  39465. clipPlane6: Nullable<Plane>;
  39466. /**
  39467. * Gets or sets a boolean indicating if animations are enabled
  39468. */
  39469. animationsEnabled: boolean;
  39470. private _animationPropertiesOverride;
  39471. /**
  39472. * Gets or sets the animation properties override
  39473. */
  39474. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39475. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39476. /**
  39477. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39478. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39479. */
  39480. useConstantAnimationDeltaTime: boolean;
  39481. /**
  39482. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39483. * Please note that it requires to run a ray cast through the scene on every frame
  39484. */
  39485. constantlyUpdateMeshUnderPointer: boolean;
  39486. /**
  39487. * Defines the HTML cursor to use when hovering over interactive elements
  39488. */
  39489. hoverCursor: string;
  39490. /**
  39491. * Defines the HTML default cursor to use (empty by default)
  39492. */
  39493. defaultCursor: string;
  39494. /**
  39495. * Defines whether cursors are handled by the scene.
  39496. */
  39497. doNotHandleCursors: boolean;
  39498. /**
  39499. * This is used to call preventDefault() on pointer down
  39500. * in order to block unwanted artifacts like system double clicks
  39501. */
  39502. preventDefaultOnPointerDown: boolean;
  39503. /**
  39504. * This is used to call preventDefault() on pointer up
  39505. * in order to block unwanted artifacts like system double clicks
  39506. */
  39507. preventDefaultOnPointerUp: boolean;
  39508. /**
  39509. * Gets or sets user defined metadata
  39510. */
  39511. metadata: any;
  39512. /**
  39513. * For internal use only. Please do not use.
  39514. */
  39515. reservedDataStore: any;
  39516. /**
  39517. * Gets the name of the plugin used to load this scene (null by default)
  39518. */
  39519. loadingPluginName: string;
  39520. /**
  39521. * Use this array to add regular expressions used to disable offline support for specific urls
  39522. */
  39523. disableOfflineSupportExceptionRules: RegExp[];
  39524. /**
  39525. * An event triggered when the scene is disposed.
  39526. */
  39527. onDisposeObservable: Observable<Scene>;
  39528. private _onDisposeObserver;
  39529. /** Sets a function to be executed when this scene is disposed. */
  39530. set onDispose(callback: () => void);
  39531. /**
  39532. * An event triggered before rendering the scene (right after animations and physics)
  39533. */
  39534. onBeforeRenderObservable: Observable<Scene>;
  39535. private _onBeforeRenderObserver;
  39536. /** Sets a function to be executed before rendering this scene */
  39537. set beforeRender(callback: Nullable<() => void>);
  39538. /**
  39539. * An event triggered after rendering the scene
  39540. */
  39541. onAfterRenderObservable: Observable<Scene>;
  39542. /**
  39543. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39544. */
  39545. onAfterRenderCameraObservable: Observable<Camera>;
  39546. private _onAfterRenderObserver;
  39547. /** Sets a function to be executed after rendering this scene */
  39548. set afterRender(callback: Nullable<() => void>);
  39549. /**
  39550. * An event triggered before animating the scene
  39551. */
  39552. onBeforeAnimationsObservable: Observable<Scene>;
  39553. /**
  39554. * An event triggered after animations processing
  39555. */
  39556. onAfterAnimationsObservable: Observable<Scene>;
  39557. /**
  39558. * An event triggered before draw calls are ready to be sent
  39559. */
  39560. onBeforeDrawPhaseObservable: Observable<Scene>;
  39561. /**
  39562. * An event triggered after draw calls have been sent
  39563. */
  39564. onAfterDrawPhaseObservable: Observable<Scene>;
  39565. /**
  39566. * An event triggered when the scene is ready
  39567. */
  39568. onReadyObservable: Observable<Scene>;
  39569. /**
  39570. * An event triggered before rendering a camera
  39571. */
  39572. onBeforeCameraRenderObservable: Observable<Camera>;
  39573. private _onBeforeCameraRenderObserver;
  39574. /** Sets a function to be executed before rendering a camera*/
  39575. set beforeCameraRender(callback: () => void);
  39576. /**
  39577. * An event triggered after rendering a camera
  39578. */
  39579. onAfterCameraRenderObservable: Observable<Camera>;
  39580. private _onAfterCameraRenderObserver;
  39581. /** Sets a function to be executed after rendering a camera*/
  39582. set afterCameraRender(callback: () => void);
  39583. /**
  39584. * An event triggered when active meshes evaluation is about to start
  39585. */
  39586. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39587. /**
  39588. * An event triggered when active meshes evaluation is done
  39589. */
  39590. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39591. /**
  39592. * An event triggered when particles rendering is about to start
  39593. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39594. */
  39595. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39596. /**
  39597. * An event triggered when particles rendering is done
  39598. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39599. */
  39600. onAfterParticlesRenderingObservable: Observable<Scene>;
  39601. /**
  39602. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39603. */
  39604. onDataLoadedObservable: Observable<Scene>;
  39605. /**
  39606. * An event triggered when a camera is created
  39607. */
  39608. onNewCameraAddedObservable: Observable<Camera>;
  39609. /**
  39610. * An event triggered when a camera is removed
  39611. */
  39612. onCameraRemovedObservable: Observable<Camera>;
  39613. /**
  39614. * An event triggered when a light is created
  39615. */
  39616. onNewLightAddedObservable: Observable<Light>;
  39617. /**
  39618. * An event triggered when a light is removed
  39619. */
  39620. onLightRemovedObservable: Observable<Light>;
  39621. /**
  39622. * An event triggered when a geometry is created
  39623. */
  39624. onNewGeometryAddedObservable: Observable<Geometry>;
  39625. /**
  39626. * An event triggered when a geometry is removed
  39627. */
  39628. onGeometryRemovedObservable: Observable<Geometry>;
  39629. /**
  39630. * An event triggered when a transform node is created
  39631. */
  39632. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39633. /**
  39634. * An event triggered when a transform node is removed
  39635. */
  39636. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39637. /**
  39638. * An event triggered when a mesh is created
  39639. */
  39640. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39641. /**
  39642. * An event triggered when a mesh is removed
  39643. */
  39644. onMeshRemovedObservable: Observable<AbstractMesh>;
  39645. /**
  39646. * An event triggered when a skeleton is created
  39647. */
  39648. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39649. /**
  39650. * An event triggered when a skeleton is removed
  39651. */
  39652. onSkeletonRemovedObservable: Observable<Skeleton>;
  39653. /**
  39654. * An event triggered when a material is created
  39655. */
  39656. onNewMaterialAddedObservable: Observable<Material>;
  39657. /**
  39658. * An event triggered when a material is removed
  39659. */
  39660. onMaterialRemovedObservable: Observable<Material>;
  39661. /**
  39662. * An event triggered when a texture is created
  39663. */
  39664. onNewTextureAddedObservable: Observable<BaseTexture>;
  39665. /**
  39666. * An event triggered when a texture is removed
  39667. */
  39668. onTextureRemovedObservable: Observable<BaseTexture>;
  39669. /**
  39670. * An event triggered when render targets are about to be rendered
  39671. * Can happen multiple times per frame.
  39672. */
  39673. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39674. /**
  39675. * An event triggered when render targets were rendered.
  39676. * Can happen multiple times per frame.
  39677. */
  39678. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39679. /**
  39680. * An event triggered before calculating deterministic simulation step
  39681. */
  39682. onBeforeStepObservable: Observable<Scene>;
  39683. /**
  39684. * An event triggered after calculating deterministic simulation step
  39685. */
  39686. onAfterStepObservable: Observable<Scene>;
  39687. /**
  39688. * An event triggered when the activeCamera property is updated
  39689. */
  39690. onActiveCameraChanged: Observable<Scene>;
  39691. /**
  39692. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39693. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39694. * 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)
  39695. */
  39696. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39697. /**
  39698. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39699. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39700. * 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)
  39701. */
  39702. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39703. /**
  39704. * This Observable will when a mesh has been imported into the scene.
  39705. */
  39706. onMeshImportedObservable: Observable<AbstractMesh>;
  39707. /**
  39708. * This Observable will when an animation file has been imported into the scene.
  39709. */
  39710. onAnimationFileImportedObservable: Observable<Scene>;
  39711. /**
  39712. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39713. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39714. */
  39715. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39716. /** @hidden */
  39717. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39718. /**
  39719. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39720. */
  39721. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39722. /**
  39723. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39724. */
  39725. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39726. /**
  39727. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39728. */
  39729. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39730. /** Callback called when a pointer move is detected */
  39731. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39732. /** Callback called when a pointer down is detected */
  39733. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39734. /** Callback called when a pointer up is detected */
  39735. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39736. /** Callback called when a pointer pick is detected */
  39737. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39738. /**
  39739. * 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).
  39740. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39741. */
  39742. onPrePointerObservable: Observable<PointerInfoPre>;
  39743. /**
  39744. * Observable event triggered each time an input event is received from the rendering canvas
  39745. */
  39746. onPointerObservable: Observable<PointerInfo>;
  39747. /**
  39748. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39749. */
  39750. get unTranslatedPointer(): Vector2;
  39751. /**
  39752. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39753. */
  39754. static get DragMovementThreshold(): number;
  39755. static set DragMovementThreshold(value: number);
  39756. /**
  39757. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39758. */
  39759. static get LongPressDelay(): number;
  39760. static set LongPressDelay(value: number);
  39761. /**
  39762. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39763. */
  39764. static get DoubleClickDelay(): number;
  39765. static set DoubleClickDelay(value: number);
  39766. /** If you need to check double click without raising a single click at first click, enable this flag */
  39767. static get ExclusiveDoubleClickMode(): boolean;
  39768. static set ExclusiveDoubleClickMode(value: boolean);
  39769. /** @hidden */
  39770. _mirroredCameraPosition: Nullable<Vector3>;
  39771. /**
  39772. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39773. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39774. */
  39775. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39776. /**
  39777. * Observable event triggered each time an keyboard event is received from the hosting window
  39778. */
  39779. onKeyboardObservable: Observable<KeyboardInfo>;
  39780. private _useRightHandedSystem;
  39781. /**
  39782. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39783. */
  39784. set useRightHandedSystem(value: boolean);
  39785. get useRightHandedSystem(): boolean;
  39786. private _timeAccumulator;
  39787. private _currentStepId;
  39788. private _currentInternalStep;
  39789. /**
  39790. * Sets the step Id used by deterministic lock step
  39791. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39792. * @param newStepId defines the step Id
  39793. */
  39794. setStepId(newStepId: number): void;
  39795. /**
  39796. * Gets the step Id used by deterministic lock step
  39797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39798. * @returns the step Id
  39799. */
  39800. getStepId(): number;
  39801. /**
  39802. * Gets the internal step used by deterministic lock step
  39803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39804. * @returns the internal step
  39805. */
  39806. getInternalStep(): number;
  39807. private _fogEnabled;
  39808. /**
  39809. * Gets or sets a boolean indicating if fog is enabled on this scene
  39810. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39811. * (Default is true)
  39812. */
  39813. set fogEnabled(value: boolean);
  39814. get fogEnabled(): boolean;
  39815. private _fogMode;
  39816. /**
  39817. * Gets or sets the fog mode to use
  39818. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39819. * | mode | value |
  39820. * | --- | --- |
  39821. * | FOGMODE_NONE | 0 |
  39822. * | FOGMODE_EXP | 1 |
  39823. * | FOGMODE_EXP2 | 2 |
  39824. * | FOGMODE_LINEAR | 3 |
  39825. */
  39826. set fogMode(value: number);
  39827. get fogMode(): number;
  39828. /**
  39829. * Gets or sets the fog color to use
  39830. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39831. * (Default is Color3(0.2, 0.2, 0.3))
  39832. */
  39833. fogColor: Color3;
  39834. /**
  39835. * Gets or sets the fog density to use
  39836. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39837. * (Default is 0.1)
  39838. */
  39839. fogDensity: number;
  39840. /**
  39841. * Gets or sets the fog start distance to use
  39842. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39843. * (Default is 0)
  39844. */
  39845. fogStart: number;
  39846. /**
  39847. * Gets or sets the fog end distance to use
  39848. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39849. * (Default is 1000)
  39850. */
  39851. fogEnd: number;
  39852. /**
  39853. * Flag indicating that the frame buffer binding is handled by another component
  39854. */
  39855. prePass: boolean;
  39856. private _shadowsEnabled;
  39857. /**
  39858. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39859. */
  39860. set shadowsEnabled(value: boolean);
  39861. get shadowsEnabled(): boolean;
  39862. private _lightsEnabled;
  39863. /**
  39864. * Gets or sets a boolean indicating if lights are enabled on this scene
  39865. */
  39866. set lightsEnabled(value: boolean);
  39867. get lightsEnabled(): boolean;
  39868. /** All of the active cameras added to this scene. */
  39869. activeCameras: Camera[];
  39870. /** @hidden */
  39871. _activeCamera: Nullable<Camera>;
  39872. /** Gets or sets the current active camera */
  39873. get activeCamera(): Nullable<Camera>;
  39874. set activeCamera(value: Nullable<Camera>);
  39875. private _defaultMaterial;
  39876. /** The default material used on meshes when no material is affected */
  39877. get defaultMaterial(): Material;
  39878. /** The default material used on meshes when no material is affected */
  39879. set defaultMaterial(value: Material);
  39880. private _texturesEnabled;
  39881. /**
  39882. * Gets or sets a boolean indicating if textures are enabled on this scene
  39883. */
  39884. set texturesEnabled(value: boolean);
  39885. get texturesEnabled(): boolean;
  39886. /**
  39887. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39888. */
  39889. physicsEnabled: boolean;
  39890. /**
  39891. * Gets or sets a boolean indicating if particles are enabled on this scene
  39892. */
  39893. particlesEnabled: boolean;
  39894. /**
  39895. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39896. */
  39897. spritesEnabled: boolean;
  39898. private _skeletonsEnabled;
  39899. /**
  39900. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39901. */
  39902. set skeletonsEnabled(value: boolean);
  39903. get skeletonsEnabled(): boolean;
  39904. /**
  39905. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39906. */
  39907. lensFlaresEnabled: boolean;
  39908. /**
  39909. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39910. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39911. */
  39912. collisionsEnabled: boolean;
  39913. private _collisionCoordinator;
  39914. /** @hidden */
  39915. get collisionCoordinator(): ICollisionCoordinator;
  39916. /**
  39917. * Defines the gravity applied to this scene (used only for collisions)
  39918. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39919. */
  39920. gravity: Vector3;
  39921. /**
  39922. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39923. */
  39924. postProcessesEnabled: boolean;
  39925. /**
  39926. * Gets the current postprocess manager
  39927. */
  39928. postProcessManager: PostProcessManager;
  39929. /**
  39930. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39931. */
  39932. renderTargetsEnabled: boolean;
  39933. /**
  39934. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39935. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39936. */
  39937. dumpNextRenderTargets: boolean;
  39938. /**
  39939. * The list of user defined render targets added to the scene
  39940. */
  39941. customRenderTargets: RenderTargetTexture[];
  39942. /**
  39943. * Defines if texture loading must be delayed
  39944. * If true, textures will only be loaded when they need to be rendered
  39945. */
  39946. useDelayedTextureLoading: boolean;
  39947. /**
  39948. * Gets the list of meshes imported to the scene through SceneLoader
  39949. */
  39950. importedMeshesFiles: String[];
  39951. /**
  39952. * Gets or sets a boolean indicating if probes are enabled on this scene
  39953. */
  39954. probesEnabled: boolean;
  39955. /**
  39956. * Gets or sets the current offline provider to use to store scene data
  39957. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39958. */
  39959. offlineProvider: IOfflineProvider;
  39960. /**
  39961. * Gets or sets the action manager associated with the scene
  39962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39963. */
  39964. actionManager: AbstractActionManager;
  39965. private _meshesForIntersections;
  39966. /**
  39967. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39968. */
  39969. proceduralTexturesEnabled: boolean;
  39970. private _engine;
  39971. private _totalVertices;
  39972. /** @hidden */
  39973. _activeIndices: PerfCounter;
  39974. /** @hidden */
  39975. _activeParticles: PerfCounter;
  39976. /** @hidden */
  39977. _activeBones: PerfCounter;
  39978. private _animationRatio;
  39979. /** @hidden */
  39980. _animationTimeLast: number;
  39981. /** @hidden */
  39982. _animationTime: number;
  39983. /**
  39984. * Gets or sets a general scale for animation speed
  39985. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39986. */
  39987. animationTimeScale: number;
  39988. /** @hidden */
  39989. _cachedMaterial: Nullable<Material>;
  39990. /** @hidden */
  39991. _cachedEffect: Nullable<Effect>;
  39992. /** @hidden */
  39993. _cachedVisibility: Nullable<number>;
  39994. private _renderId;
  39995. private _frameId;
  39996. private _executeWhenReadyTimeoutId;
  39997. private _intermediateRendering;
  39998. private _viewUpdateFlag;
  39999. private _projectionUpdateFlag;
  40000. /** @hidden */
  40001. _toBeDisposed: Nullable<IDisposable>[];
  40002. private _activeRequests;
  40003. /** @hidden */
  40004. _pendingData: any[];
  40005. private _isDisposed;
  40006. /**
  40007. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40008. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40009. */
  40010. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40011. private _activeMeshes;
  40012. private _processedMaterials;
  40013. private _renderTargets;
  40014. /** @hidden */
  40015. _activeParticleSystems: SmartArray<IParticleSystem>;
  40016. private _activeSkeletons;
  40017. private _softwareSkinnedMeshes;
  40018. private _renderingManager;
  40019. /** @hidden */
  40020. _activeAnimatables: Animatable[];
  40021. private _transformMatrix;
  40022. private _sceneUbo;
  40023. /** @hidden */
  40024. _viewMatrix: Matrix;
  40025. private _projectionMatrix;
  40026. /** @hidden */
  40027. _forcedViewPosition: Nullable<Vector3>;
  40028. /** @hidden */
  40029. _frustumPlanes: Plane[];
  40030. /**
  40031. * Gets the list of frustum planes (built from the active camera)
  40032. */
  40033. get frustumPlanes(): Plane[];
  40034. /**
  40035. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40036. * This is useful if there are more lights that the maximum simulteanous authorized
  40037. */
  40038. requireLightSorting: boolean;
  40039. /** @hidden */
  40040. readonly useMaterialMeshMap: boolean;
  40041. /** @hidden */
  40042. readonly useClonedMeshMap: boolean;
  40043. private _externalData;
  40044. private _uid;
  40045. /**
  40046. * @hidden
  40047. * Backing store of defined scene components.
  40048. */
  40049. _components: ISceneComponent[];
  40050. /**
  40051. * @hidden
  40052. * Backing store of defined scene components.
  40053. */
  40054. _serializableComponents: ISceneSerializableComponent[];
  40055. /**
  40056. * List of components to register on the next registration step.
  40057. */
  40058. private _transientComponents;
  40059. /**
  40060. * Registers the transient components if needed.
  40061. */
  40062. private _registerTransientComponents;
  40063. /**
  40064. * @hidden
  40065. * Add a component to the scene.
  40066. * Note that the ccomponent could be registered on th next frame if this is called after
  40067. * the register component stage.
  40068. * @param component Defines the component to add to the scene
  40069. */
  40070. _addComponent(component: ISceneComponent): void;
  40071. /**
  40072. * @hidden
  40073. * Gets a component from the scene.
  40074. * @param name defines the name of the component to retrieve
  40075. * @returns the component or null if not present
  40076. */
  40077. _getComponent(name: string): Nullable<ISceneComponent>;
  40078. /**
  40079. * @hidden
  40080. * Defines the actions happening before camera updates.
  40081. */
  40082. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40083. /**
  40084. * @hidden
  40085. * Defines the actions happening before clear the canvas.
  40086. */
  40087. _beforeClearStage: Stage<SimpleStageAction>;
  40088. /**
  40089. * @hidden
  40090. * Defines the actions when collecting render targets for the frame.
  40091. */
  40092. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40093. /**
  40094. * @hidden
  40095. * Defines the actions happening for one camera in the frame.
  40096. */
  40097. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40098. /**
  40099. * @hidden
  40100. * Defines the actions happening during the per mesh ready checks.
  40101. */
  40102. _isReadyForMeshStage: Stage<MeshStageAction>;
  40103. /**
  40104. * @hidden
  40105. * Defines the actions happening before evaluate active mesh checks.
  40106. */
  40107. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40108. /**
  40109. * @hidden
  40110. * Defines the actions happening during the evaluate sub mesh checks.
  40111. */
  40112. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40113. /**
  40114. * @hidden
  40115. * Defines the actions happening during the active mesh stage.
  40116. */
  40117. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40118. /**
  40119. * @hidden
  40120. * Defines the actions happening during the per camera render target step.
  40121. */
  40122. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40123. /**
  40124. * @hidden
  40125. * Defines the actions happening just before the active camera is drawing.
  40126. */
  40127. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40128. /**
  40129. * @hidden
  40130. * Defines the actions happening just before a render target is drawing.
  40131. */
  40132. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40133. /**
  40134. * @hidden
  40135. * Defines the actions happening just before a rendering group is drawing.
  40136. */
  40137. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40138. /**
  40139. * @hidden
  40140. * Defines the actions happening just before a mesh is drawing.
  40141. */
  40142. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40143. /**
  40144. * @hidden
  40145. * Defines the actions happening just after a mesh has been drawn.
  40146. */
  40147. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40148. /**
  40149. * @hidden
  40150. * Defines the actions happening just after a rendering group has been drawn.
  40151. */
  40152. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40153. /**
  40154. * @hidden
  40155. * Defines the actions happening just after the active camera has been drawn.
  40156. */
  40157. _afterCameraDrawStage: Stage<CameraStageAction>;
  40158. /**
  40159. * @hidden
  40160. * Defines the actions happening just after a render target has been drawn.
  40161. */
  40162. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40163. /**
  40164. * @hidden
  40165. * Defines the actions happening just after rendering all cameras and computing intersections.
  40166. */
  40167. _afterRenderStage: Stage<SimpleStageAction>;
  40168. /**
  40169. * @hidden
  40170. * Defines the actions happening when a pointer move event happens.
  40171. */
  40172. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40173. /**
  40174. * @hidden
  40175. * Defines the actions happening when a pointer down event happens.
  40176. */
  40177. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40178. /**
  40179. * @hidden
  40180. * Defines the actions happening when a pointer up event happens.
  40181. */
  40182. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40183. /**
  40184. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40185. */
  40186. private geometriesByUniqueId;
  40187. /**
  40188. * Creates a new Scene
  40189. * @param engine defines the engine to use to render this scene
  40190. * @param options defines the scene options
  40191. */
  40192. constructor(engine: Engine, options?: SceneOptions);
  40193. /**
  40194. * Gets a string identifying the name of the class
  40195. * @returns "Scene" string
  40196. */
  40197. getClassName(): string;
  40198. private _defaultMeshCandidates;
  40199. /**
  40200. * @hidden
  40201. */
  40202. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40203. private _defaultSubMeshCandidates;
  40204. /**
  40205. * @hidden
  40206. */
  40207. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40208. /**
  40209. * Sets the default candidate providers for the scene.
  40210. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40211. * and getCollidingSubMeshCandidates to their default function
  40212. */
  40213. setDefaultCandidateProviders(): void;
  40214. /**
  40215. * Gets the mesh that is currently under the pointer
  40216. */
  40217. get meshUnderPointer(): Nullable<AbstractMesh>;
  40218. /**
  40219. * Gets or sets the current on-screen X position of the pointer
  40220. */
  40221. get pointerX(): number;
  40222. set pointerX(value: number);
  40223. /**
  40224. * Gets or sets the current on-screen Y position of the pointer
  40225. */
  40226. get pointerY(): number;
  40227. set pointerY(value: number);
  40228. /**
  40229. * Gets the cached material (ie. the latest rendered one)
  40230. * @returns the cached material
  40231. */
  40232. getCachedMaterial(): Nullable<Material>;
  40233. /**
  40234. * Gets the cached effect (ie. the latest rendered one)
  40235. * @returns the cached effect
  40236. */
  40237. getCachedEffect(): Nullable<Effect>;
  40238. /**
  40239. * Gets the cached visibility state (ie. the latest rendered one)
  40240. * @returns the cached visibility state
  40241. */
  40242. getCachedVisibility(): Nullable<number>;
  40243. /**
  40244. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40245. * @param material defines the current material
  40246. * @param effect defines the current effect
  40247. * @param visibility defines the current visibility state
  40248. * @returns true if one parameter is not cached
  40249. */
  40250. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40251. /**
  40252. * Gets the engine associated with the scene
  40253. * @returns an Engine
  40254. */
  40255. getEngine(): Engine;
  40256. /**
  40257. * Gets the total number of vertices rendered per frame
  40258. * @returns the total number of vertices rendered per frame
  40259. */
  40260. getTotalVertices(): number;
  40261. /**
  40262. * Gets the performance counter for total vertices
  40263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40264. */
  40265. get totalVerticesPerfCounter(): PerfCounter;
  40266. /**
  40267. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40268. * @returns the total number of active indices rendered per frame
  40269. */
  40270. getActiveIndices(): number;
  40271. /**
  40272. * Gets the performance counter for active indices
  40273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40274. */
  40275. get totalActiveIndicesPerfCounter(): PerfCounter;
  40276. /**
  40277. * Gets the total number of active particles rendered per frame
  40278. * @returns the total number of active particles rendered per frame
  40279. */
  40280. getActiveParticles(): number;
  40281. /**
  40282. * Gets the performance counter for active particles
  40283. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40284. */
  40285. get activeParticlesPerfCounter(): PerfCounter;
  40286. /**
  40287. * Gets the total number of active bones rendered per frame
  40288. * @returns the total number of active bones rendered per frame
  40289. */
  40290. getActiveBones(): number;
  40291. /**
  40292. * Gets the performance counter for active bones
  40293. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40294. */
  40295. get activeBonesPerfCounter(): PerfCounter;
  40296. /**
  40297. * Gets the array of active meshes
  40298. * @returns an array of AbstractMesh
  40299. */
  40300. getActiveMeshes(): SmartArray<AbstractMesh>;
  40301. /**
  40302. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40303. * @returns a number
  40304. */
  40305. getAnimationRatio(): number;
  40306. /**
  40307. * Gets an unique Id for the current render phase
  40308. * @returns a number
  40309. */
  40310. getRenderId(): number;
  40311. /**
  40312. * Gets an unique Id for the current frame
  40313. * @returns a number
  40314. */
  40315. getFrameId(): number;
  40316. /** Call this function if you want to manually increment the render Id*/
  40317. incrementRenderId(): void;
  40318. private _createUbo;
  40319. /**
  40320. * Use this method to simulate a pointer move on a mesh
  40321. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40322. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40323. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40324. * @returns the current scene
  40325. */
  40326. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40327. /**
  40328. * Use this method to simulate a pointer down on a mesh
  40329. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40330. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40331. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40332. * @returns the current scene
  40333. */
  40334. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40335. /**
  40336. * Use this method to simulate a pointer up on a mesh
  40337. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40338. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40339. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40340. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40341. * @returns the current scene
  40342. */
  40343. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40344. /**
  40345. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40346. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40347. * @returns true if the pointer was captured
  40348. */
  40349. isPointerCaptured(pointerId?: number): boolean;
  40350. /**
  40351. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40352. * @param attachUp defines if you want to attach events to pointerup
  40353. * @param attachDown defines if you want to attach events to pointerdown
  40354. * @param attachMove defines if you want to attach events to pointermove
  40355. */
  40356. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40357. /** Detaches all event handlers*/
  40358. detachControl(): void;
  40359. /**
  40360. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40361. * Delay loaded resources are not taking in account
  40362. * @return true if all required resources are ready
  40363. */
  40364. isReady(): boolean;
  40365. /** Resets all cached information relative to material (including effect and visibility) */
  40366. resetCachedMaterial(): void;
  40367. /**
  40368. * Registers a function to be called before every frame render
  40369. * @param func defines the function to register
  40370. */
  40371. registerBeforeRender(func: () => void): void;
  40372. /**
  40373. * Unregisters a function called before every frame render
  40374. * @param func defines the function to unregister
  40375. */
  40376. unregisterBeforeRender(func: () => void): void;
  40377. /**
  40378. * Registers a function to be called after every frame render
  40379. * @param func defines the function to register
  40380. */
  40381. registerAfterRender(func: () => void): void;
  40382. /**
  40383. * Unregisters a function called after every frame render
  40384. * @param func defines the function to unregister
  40385. */
  40386. unregisterAfterRender(func: () => void): void;
  40387. private _executeOnceBeforeRender;
  40388. /**
  40389. * The provided function will run before render once and will be disposed afterwards.
  40390. * A timeout delay can be provided so that the function will be executed in N ms.
  40391. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40392. * @param func The function to be executed.
  40393. * @param timeout optional delay in ms
  40394. */
  40395. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40396. /** @hidden */
  40397. _addPendingData(data: any): void;
  40398. /** @hidden */
  40399. _removePendingData(data: any): void;
  40400. /**
  40401. * Returns the number of items waiting to be loaded
  40402. * @returns the number of items waiting to be loaded
  40403. */
  40404. getWaitingItemsCount(): number;
  40405. /**
  40406. * Returns a boolean indicating if the scene is still loading data
  40407. */
  40408. get isLoading(): boolean;
  40409. /**
  40410. * Registers a function to be executed when the scene is ready
  40411. * @param {Function} func - the function to be executed
  40412. */
  40413. executeWhenReady(func: () => void): void;
  40414. /**
  40415. * Returns a promise that resolves when the scene is ready
  40416. * @returns A promise that resolves when the scene is ready
  40417. */
  40418. whenReadyAsync(): Promise<void>;
  40419. /** @hidden */
  40420. _checkIsReady(): void;
  40421. /**
  40422. * Gets all animatable attached to the scene
  40423. */
  40424. get animatables(): Animatable[];
  40425. /**
  40426. * Resets the last animation time frame.
  40427. * Useful to override when animations start running when loading a scene for the first time.
  40428. */
  40429. resetLastAnimationTimeFrame(): void;
  40430. /**
  40431. * Gets the current view matrix
  40432. * @returns a Matrix
  40433. */
  40434. getViewMatrix(): Matrix;
  40435. /**
  40436. * Gets the current projection matrix
  40437. * @returns a Matrix
  40438. */
  40439. getProjectionMatrix(): Matrix;
  40440. /**
  40441. * Gets the current transform matrix
  40442. * @returns a Matrix made of View * Projection
  40443. */
  40444. getTransformMatrix(): Matrix;
  40445. /**
  40446. * Sets the current transform matrix
  40447. * @param viewL defines the View matrix to use
  40448. * @param projectionL defines the Projection matrix to use
  40449. * @param viewR defines the right View matrix to use (if provided)
  40450. * @param projectionR defines the right Projection matrix to use (if provided)
  40451. */
  40452. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40453. /**
  40454. * Gets the uniform buffer used to store scene data
  40455. * @returns a UniformBuffer
  40456. */
  40457. getSceneUniformBuffer(): UniformBuffer;
  40458. /**
  40459. * Gets an unique (relatively to the current scene) Id
  40460. * @returns an unique number for the scene
  40461. */
  40462. getUniqueId(): number;
  40463. /**
  40464. * Add a mesh to the list of scene's meshes
  40465. * @param newMesh defines the mesh to add
  40466. * @param recursive if all child meshes should also be added to the scene
  40467. */
  40468. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40469. /**
  40470. * Remove a mesh for the list of scene's meshes
  40471. * @param toRemove defines the mesh to remove
  40472. * @param recursive if all child meshes should also be removed from the scene
  40473. * @returns the index where the mesh was in the mesh list
  40474. */
  40475. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40476. /**
  40477. * Add a transform node to the list of scene's transform nodes
  40478. * @param newTransformNode defines the transform node to add
  40479. */
  40480. addTransformNode(newTransformNode: TransformNode): void;
  40481. /**
  40482. * Remove a transform node for the list of scene's transform nodes
  40483. * @param toRemove defines the transform node to remove
  40484. * @returns the index where the transform node was in the transform node list
  40485. */
  40486. removeTransformNode(toRemove: TransformNode): number;
  40487. /**
  40488. * Remove a skeleton for the list of scene's skeletons
  40489. * @param toRemove defines the skeleton to remove
  40490. * @returns the index where the skeleton was in the skeleton list
  40491. */
  40492. removeSkeleton(toRemove: Skeleton): number;
  40493. /**
  40494. * Remove a morph target for the list of scene's morph targets
  40495. * @param toRemove defines the morph target to remove
  40496. * @returns the index where the morph target was in the morph target list
  40497. */
  40498. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40499. /**
  40500. * Remove a light for the list of scene's lights
  40501. * @param toRemove defines the light to remove
  40502. * @returns the index where the light was in the light list
  40503. */
  40504. removeLight(toRemove: Light): number;
  40505. /**
  40506. * Remove a camera for the list of scene's cameras
  40507. * @param toRemove defines the camera to remove
  40508. * @returns the index where the camera was in the camera list
  40509. */
  40510. removeCamera(toRemove: Camera): number;
  40511. /**
  40512. * Remove a particle system for the list of scene's particle systems
  40513. * @param toRemove defines the particle system to remove
  40514. * @returns the index where the particle system was in the particle system list
  40515. */
  40516. removeParticleSystem(toRemove: IParticleSystem): number;
  40517. /**
  40518. * Remove a animation for the list of scene's animations
  40519. * @param toRemove defines the animation to remove
  40520. * @returns the index where the animation was in the animation list
  40521. */
  40522. removeAnimation(toRemove: Animation): number;
  40523. /**
  40524. * Will stop the animation of the given target
  40525. * @param target - the target
  40526. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40527. * @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)
  40528. */
  40529. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40530. /**
  40531. * Removes the given animation group from this scene.
  40532. * @param toRemove The animation group to remove
  40533. * @returns The index of the removed animation group
  40534. */
  40535. removeAnimationGroup(toRemove: AnimationGroup): number;
  40536. /**
  40537. * Removes the given multi-material from this scene.
  40538. * @param toRemove The multi-material to remove
  40539. * @returns The index of the removed multi-material
  40540. */
  40541. removeMultiMaterial(toRemove: MultiMaterial): number;
  40542. /**
  40543. * Removes the given material from this scene.
  40544. * @param toRemove The material to remove
  40545. * @returns The index of the removed material
  40546. */
  40547. removeMaterial(toRemove: Material): number;
  40548. /**
  40549. * Removes the given action manager from this scene.
  40550. * @param toRemove The action manager to remove
  40551. * @returns The index of the removed action manager
  40552. */
  40553. removeActionManager(toRemove: AbstractActionManager): number;
  40554. /**
  40555. * Removes the given texture from this scene.
  40556. * @param toRemove The texture to remove
  40557. * @returns The index of the removed texture
  40558. */
  40559. removeTexture(toRemove: BaseTexture): number;
  40560. /**
  40561. * Adds the given light to this scene
  40562. * @param newLight The light to add
  40563. */
  40564. addLight(newLight: Light): void;
  40565. /**
  40566. * Sorts the list list based on light priorities
  40567. */
  40568. sortLightsByPriority(): void;
  40569. /**
  40570. * Adds the given camera to this scene
  40571. * @param newCamera The camera to add
  40572. */
  40573. addCamera(newCamera: Camera): void;
  40574. /**
  40575. * Adds the given skeleton to this scene
  40576. * @param newSkeleton The skeleton to add
  40577. */
  40578. addSkeleton(newSkeleton: Skeleton): void;
  40579. /**
  40580. * Adds the given particle system to this scene
  40581. * @param newParticleSystem The particle system to add
  40582. */
  40583. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40584. /**
  40585. * Adds the given animation to this scene
  40586. * @param newAnimation The animation to add
  40587. */
  40588. addAnimation(newAnimation: Animation): void;
  40589. /**
  40590. * Adds the given animation group to this scene.
  40591. * @param newAnimationGroup The animation group to add
  40592. */
  40593. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40594. /**
  40595. * Adds the given multi-material to this scene
  40596. * @param newMultiMaterial The multi-material to add
  40597. */
  40598. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40599. /**
  40600. * Adds the given material to this scene
  40601. * @param newMaterial The material to add
  40602. */
  40603. addMaterial(newMaterial: Material): void;
  40604. /**
  40605. * Adds the given morph target to this scene
  40606. * @param newMorphTargetManager The morph target to add
  40607. */
  40608. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40609. /**
  40610. * Adds the given geometry to this scene
  40611. * @param newGeometry The geometry to add
  40612. */
  40613. addGeometry(newGeometry: Geometry): void;
  40614. /**
  40615. * Adds the given action manager to this scene
  40616. * @param newActionManager The action manager to add
  40617. */
  40618. addActionManager(newActionManager: AbstractActionManager): void;
  40619. /**
  40620. * Adds the given texture to this scene.
  40621. * @param newTexture The texture to add
  40622. */
  40623. addTexture(newTexture: BaseTexture): void;
  40624. /**
  40625. * Switch active camera
  40626. * @param newCamera defines the new active camera
  40627. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40628. */
  40629. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40630. /**
  40631. * sets the active camera of the scene using its ID
  40632. * @param id defines the camera's ID
  40633. * @return the new active camera or null if none found.
  40634. */
  40635. setActiveCameraByID(id: string): Nullable<Camera>;
  40636. /**
  40637. * sets the active camera of the scene using its name
  40638. * @param name defines the camera's name
  40639. * @returns the new active camera or null if none found.
  40640. */
  40641. setActiveCameraByName(name: string): Nullable<Camera>;
  40642. /**
  40643. * get an animation group using its name
  40644. * @param name defines the material's name
  40645. * @return the animation group or null if none found.
  40646. */
  40647. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40648. /**
  40649. * Get a material using its unique id
  40650. * @param uniqueId defines the material's unique id
  40651. * @return the material or null if none found.
  40652. */
  40653. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40654. /**
  40655. * get a material using its id
  40656. * @param id defines the material's ID
  40657. * @return the material or null if none found.
  40658. */
  40659. getMaterialByID(id: string): Nullable<Material>;
  40660. /**
  40661. * Gets a the last added material using a given id
  40662. * @param id defines the material's ID
  40663. * @return the last material with the given id or null if none found.
  40664. */
  40665. getLastMaterialByID(id: string): Nullable<Material>;
  40666. /**
  40667. * Gets a material using its name
  40668. * @param name defines the material's name
  40669. * @return the material or null if none found.
  40670. */
  40671. getMaterialByName(name: string): Nullable<Material>;
  40672. /**
  40673. * Get a texture using its unique id
  40674. * @param uniqueId defines the texture's unique id
  40675. * @return the texture or null if none found.
  40676. */
  40677. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40678. /**
  40679. * Gets a camera using its id
  40680. * @param id defines the id to look for
  40681. * @returns the camera or null if not found
  40682. */
  40683. getCameraByID(id: string): Nullable<Camera>;
  40684. /**
  40685. * Gets a camera using its unique id
  40686. * @param uniqueId defines the unique id to look for
  40687. * @returns the camera or null if not found
  40688. */
  40689. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40690. /**
  40691. * Gets a camera using its name
  40692. * @param name defines the camera's name
  40693. * @return the camera or null if none found.
  40694. */
  40695. getCameraByName(name: string): Nullable<Camera>;
  40696. /**
  40697. * Gets a bone using its id
  40698. * @param id defines the bone's id
  40699. * @return the bone or null if not found
  40700. */
  40701. getBoneByID(id: string): Nullable<Bone>;
  40702. /**
  40703. * Gets a bone using its id
  40704. * @param name defines the bone's name
  40705. * @return the bone or null if not found
  40706. */
  40707. getBoneByName(name: string): Nullable<Bone>;
  40708. /**
  40709. * Gets a light node using its name
  40710. * @param name defines the the light's name
  40711. * @return the light or null if none found.
  40712. */
  40713. getLightByName(name: string): Nullable<Light>;
  40714. /**
  40715. * Gets a light node using its id
  40716. * @param id defines the light's id
  40717. * @return the light or null if none found.
  40718. */
  40719. getLightByID(id: string): Nullable<Light>;
  40720. /**
  40721. * Gets a light node using its scene-generated unique ID
  40722. * @param uniqueId defines the light's unique id
  40723. * @return the light or null if none found.
  40724. */
  40725. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40726. /**
  40727. * Gets a particle system by id
  40728. * @param id defines the particle system id
  40729. * @return the corresponding system or null if none found
  40730. */
  40731. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40732. /**
  40733. * Gets a geometry using its ID
  40734. * @param id defines the geometry's id
  40735. * @return the geometry or null if none found.
  40736. */
  40737. getGeometryByID(id: string): Nullable<Geometry>;
  40738. private _getGeometryByUniqueID;
  40739. /**
  40740. * Add a new geometry to this scene
  40741. * @param geometry defines the geometry to be added to the scene.
  40742. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40743. * @return a boolean defining if the geometry was added or not
  40744. */
  40745. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40746. /**
  40747. * Removes an existing geometry
  40748. * @param geometry defines the geometry to be removed from the scene
  40749. * @return a boolean defining if the geometry was removed or not
  40750. */
  40751. removeGeometry(geometry: Geometry): boolean;
  40752. /**
  40753. * Gets the list of geometries attached to the scene
  40754. * @returns an array of Geometry
  40755. */
  40756. getGeometries(): Geometry[];
  40757. /**
  40758. * Gets the first added mesh found of a given ID
  40759. * @param id defines the id to search for
  40760. * @return the mesh found or null if not found at all
  40761. */
  40762. getMeshByID(id: string): Nullable<AbstractMesh>;
  40763. /**
  40764. * Gets a list of meshes using their id
  40765. * @param id defines the id to search for
  40766. * @returns a list of meshes
  40767. */
  40768. getMeshesByID(id: string): Array<AbstractMesh>;
  40769. /**
  40770. * Gets the first added transform node found of a given ID
  40771. * @param id defines the id to search for
  40772. * @return the found transform node or null if not found at all.
  40773. */
  40774. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40775. /**
  40776. * Gets a transform node with its auto-generated unique id
  40777. * @param uniqueId efines the unique id to search for
  40778. * @return the found transform node or null if not found at all.
  40779. */
  40780. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40781. /**
  40782. * Gets a list of transform nodes using their id
  40783. * @param id defines the id to search for
  40784. * @returns a list of transform nodes
  40785. */
  40786. getTransformNodesByID(id: string): Array<TransformNode>;
  40787. /**
  40788. * Gets a mesh with its auto-generated unique id
  40789. * @param uniqueId defines the unique id to search for
  40790. * @return the found mesh or null if not found at all.
  40791. */
  40792. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40793. /**
  40794. * Gets a the last added mesh using a given id
  40795. * @param id defines the id to search for
  40796. * @return the found mesh or null if not found at all.
  40797. */
  40798. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40799. /**
  40800. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40801. * @param id defines the id to search for
  40802. * @return the found node or null if not found at all
  40803. */
  40804. getLastEntryByID(id: string): Nullable<Node>;
  40805. /**
  40806. * Gets a node (Mesh, Camera, Light) using a given id
  40807. * @param id defines the id to search for
  40808. * @return the found node or null if not found at all
  40809. */
  40810. getNodeByID(id: string): Nullable<Node>;
  40811. /**
  40812. * Gets a node (Mesh, Camera, Light) using a given name
  40813. * @param name defines the name to search for
  40814. * @return the found node or null if not found at all.
  40815. */
  40816. getNodeByName(name: string): Nullable<Node>;
  40817. /**
  40818. * Gets a mesh using a given name
  40819. * @param name defines the name to search for
  40820. * @return the found mesh or null if not found at all.
  40821. */
  40822. getMeshByName(name: string): Nullable<AbstractMesh>;
  40823. /**
  40824. * Gets a transform node using a given name
  40825. * @param name defines the name to search for
  40826. * @return the found transform node or null if not found at all.
  40827. */
  40828. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40829. /**
  40830. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40831. * @param id defines the id to search for
  40832. * @return the found skeleton or null if not found at all.
  40833. */
  40834. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40835. /**
  40836. * Gets a skeleton using a given auto generated unique id
  40837. * @param uniqueId defines the unique id to search for
  40838. * @return the found skeleton or null if not found at all.
  40839. */
  40840. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40841. /**
  40842. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40843. * @param id defines the id to search for
  40844. * @return the found skeleton or null if not found at all.
  40845. */
  40846. getSkeletonById(id: string): Nullable<Skeleton>;
  40847. /**
  40848. * Gets a skeleton using a given name
  40849. * @param name defines the name to search for
  40850. * @return the found skeleton or null if not found at all.
  40851. */
  40852. getSkeletonByName(name: string): Nullable<Skeleton>;
  40853. /**
  40854. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40855. * @param id defines the id to search for
  40856. * @return the found morph target manager or null if not found at all.
  40857. */
  40858. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40859. /**
  40860. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40861. * @param id defines the id to search for
  40862. * @return the found morph target or null if not found at all.
  40863. */
  40864. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40865. /**
  40866. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40867. * @param name defines the name to search for
  40868. * @return the found morph target or null if not found at all.
  40869. */
  40870. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40871. /**
  40872. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40873. * @param name defines the name to search for
  40874. * @return the found post process or null if not found at all.
  40875. */
  40876. getPostProcessByName(name: string): Nullable<PostProcess>;
  40877. /**
  40878. * Gets a boolean indicating if the given mesh is active
  40879. * @param mesh defines the mesh to look for
  40880. * @returns true if the mesh is in the active list
  40881. */
  40882. isActiveMesh(mesh: AbstractMesh): boolean;
  40883. /**
  40884. * Return a unique id as a string which can serve as an identifier for the scene
  40885. */
  40886. get uid(): string;
  40887. /**
  40888. * Add an externaly attached data from its key.
  40889. * This method call will fail and return false, if such key already exists.
  40890. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40891. * @param key the unique key that identifies the data
  40892. * @param data the data object to associate to the key for this Engine instance
  40893. * @return true if no such key were already present and the data was added successfully, false otherwise
  40894. */
  40895. addExternalData<T>(key: string, data: T): boolean;
  40896. /**
  40897. * Get an externaly attached data from its key
  40898. * @param key the unique key that identifies the data
  40899. * @return the associated data, if present (can be null), or undefined if not present
  40900. */
  40901. getExternalData<T>(key: string): Nullable<T>;
  40902. /**
  40903. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40904. * @param key the unique key that identifies the data
  40905. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40906. * @return the associated data, can be null if the factory returned null.
  40907. */
  40908. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40909. /**
  40910. * Remove an externaly attached data from the Engine instance
  40911. * @param key the unique key that identifies the data
  40912. * @return true if the data was successfully removed, false if it doesn't exist
  40913. */
  40914. removeExternalData(key: string): boolean;
  40915. private _evaluateSubMesh;
  40916. /**
  40917. * Clear the processed materials smart array preventing retention point in material dispose.
  40918. */
  40919. freeProcessedMaterials(): void;
  40920. private _preventFreeActiveMeshesAndRenderingGroups;
  40921. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40922. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40923. * when disposing several meshes in a row or a hierarchy of meshes.
  40924. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40925. */
  40926. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40927. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40928. /**
  40929. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40930. */
  40931. freeActiveMeshes(): void;
  40932. /**
  40933. * Clear the info related to rendering groups preventing retention points during dispose.
  40934. */
  40935. freeRenderingGroups(): void;
  40936. /** @hidden */
  40937. _isInIntermediateRendering(): boolean;
  40938. /**
  40939. * Lambda returning the list of potentially active meshes.
  40940. */
  40941. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40942. /**
  40943. * Lambda returning the list of potentially active sub meshes.
  40944. */
  40945. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40946. /**
  40947. * Lambda returning the list of potentially intersecting sub meshes.
  40948. */
  40949. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40950. /**
  40951. * Lambda returning the list of potentially colliding sub meshes.
  40952. */
  40953. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40954. private _activeMeshesFrozen;
  40955. private _skipEvaluateActiveMeshesCompletely;
  40956. /**
  40957. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40958. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40959. * @returns the current scene
  40960. */
  40961. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40962. /**
  40963. * Use this function to restart evaluating active meshes on every frame
  40964. * @returns the current scene
  40965. */
  40966. unfreezeActiveMeshes(): Scene;
  40967. private _evaluateActiveMeshes;
  40968. private _activeMesh;
  40969. /**
  40970. * Update the transform matrix to update from the current active camera
  40971. * @param force defines a boolean used to force the update even if cache is up to date
  40972. */
  40973. updateTransformMatrix(force?: boolean): void;
  40974. private _bindFrameBuffer;
  40975. /** @hidden */
  40976. _allowPostProcessClearColor: boolean;
  40977. /** @hidden */
  40978. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40979. private _processSubCameras;
  40980. private _checkIntersections;
  40981. /** @hidden */
  40982. _advancePhysicsEngineStep(step: number): void;
  40983. /**
  40984. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40985. */
  40986. getDeterministicFrameTime: () => number;
  40987. /** @hidden */
  40988. _animate(): void;
  40989. /** Execute all animations (for a frame) */
  40990. animate(): void;
  40991. /**
  40992. * Render the scene
  40993. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40994. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40995. */
  40996. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40997. /**
  40998. * Freeze all materials
  40999. * A frozen material will not be updatable but should be faster to render
  41000. */
  41001. freezeMaterials(): void;
  41002. /**
  41003. * Unfreeze all materials
  41004. * A frozen material will not be updatable but should be faster to render
  41005. */
  41006. unfreezeMaterials(): void;
  41007. /**
  41008. * Releases all held ressources
  41009. */
  41010. dispose(): void;
  41011. /**
  41012. * Gets if the scene is already disposed
  41013. */
  41014. get isDisposed(): boolean;
  41015. /**
  41016. * Call this function to reduce memory footprint of the scene.
  41017. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41018. */
  41019. clearCachedVertexData(): void;
  41020. /**
  41021. * This function will remove the local cached buffer data from texture.
  41022. * It will save memory but will prevent the texture from being rebuilt
  41023. */
  41024. cleanCachedTextureBuffer(): void;
  41025. /**
  41026. * Get the world extend vectors with an optional filter
  41027. *
  41028. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41029. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41030. */
  41031. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41032. min: Vector3;
  41033. max: Vector3;
  41034. };
  41035. /**
  41036. * Creates a ray that can be used to pick in the scene
  41037. * @param x defines the x coordinate of the origin (on-screen)
  41038. * @param y defines the y coordinate of the origin (on-screen)
  41039. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41040. * @param camera defines the camera to use for the picking
  41041. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41042. * @returns a Ray
  41043. */
  41044. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41045. /**
  41046. * Creates a ray that can be used to pick in the scene
  41047. * @param x defines the x coordinate of the origin (on-screen)
  41048. * @param y defines the y coordinate of the origin (on-screen)
  41049. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41050. * @param result defines the ray where to store the picking ray
  41051. * @param camera defines the camera to use for the picking
  41052. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41053. * @returns the current scene
  41054. */
  41055. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41056. /**
  41057. * Creates a ray that can be used to pick in the scene
  41058. * @param x defines the x coordinate of the origin (on-screen)
  41059. * @param y defines the y coordinate of the origin (on-screen)
  41060. * @param camera defines the camera to use for the picking
  41061. * @returns a Ray
  41062. */
  41063. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41064. /**
  41065. * Creates a ray that can be used to pick in the scene
  41066. * @param x defines the x coordinate of the origin (on-screen)
  41067. * @param y defines the y coordinate of the origin (on-screen)
  41068. * @param result defines the ray where to store the picking ray
  41069. * @param camera defines the camera to use for the picking
  41070. * @returns the current scene
  41071. */
  41072. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41073. /** Launch a ray to try to pick a mesh in the scene
  41074. * @param x position on screen
  41075. * @param y position on screen
  41076. * @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
  41077. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41078. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41080. * @returns a PickingInfo
  41081. */
  41082. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41083. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41084. * @param x position on screen
  41085. * @param y position on screen
  41086. * @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
  41087. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41088. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41089. * @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)
  41090. */
  41091. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41092. /** Use the given ray to pick a mesh in the scene
  41093. * @param ray The ray to use to pick meshes
  41094. * @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
  41095. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41096. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41097. * @returns a PickingInfo
  41098. */
  41099. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41100. /**
  41101. * Launch a ray to try to pick a mesh in the scene
  41102. * @param x X position on screen
  41103. * @param y Y position on screen
  41104. * @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
  41105. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41106. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41107. * @returns an array of PickingInfo
  41108. */
  41109. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41110. /**
  41111. * Launch a ray to try to pick a mesh in the scene
  41112. * @param ray Ray to use
  41113. * @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
  41114. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41115. * @returns an array of PickingInfo
  41116. */
  41117. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41118. /**
  41119. * Force the value of meshUnderPointer
  41120. * @param mesh defines the mesh to use
  41121. * @param pointerId optional pointer id when using more than one pointer
  41122. */
  41123. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41124. /**
  41125. * Gets the mesh under the pointer
  41126. * @returns a Mesh or null if no mesh is under the pointer
  41127. */
  41128. getPointerOverMesh(): Nullable<AbstractMesh>;
  41129. /** @hidden */
  41130. _rebuildGeometries(): void;
  41131. /** @hidden */
  41132. _rebuildTextures(): void;
  41133. private _getByTags;
  41134. /**
  41135. * Get a list of meshes by tags
  41136. * @param tagsQuery defines the tags query to use
  41137. * @param forEach defines a predicate used to filter results
  41138. * @returns an array of Mesh
  41139. */
  41140. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41141. /**
  41142. * Get a list of cameras by tags
  41143. * @param tagsQuery defines the tags query to use
  41144. * @param forEach defines a predicate used to filter results
  41145. * @returns an array of Camera
  41146. */
  41147. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41148. /**
  41149. * Get a list of lights by tags
  41150. * @param tagsQuery defines the tags query to use
  41151. * @param forEach defines a predicate used to filter results
  41152. * @returns an array of Light
  41153. */
  41154. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41155. /**
  41156. * Get a list of materials by tags
  41157. * @param tagsQuery defines the tags query to use
  41158. * @param forEach defines a predicate used to filter results
  41159. * @returns an array of Material
  41160. */
  41161. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41162. /**
  41163. * Get a list of transform nodes by tags
  41164. * @param tagsQuery defines the tags query to use
  41165. * @param forEach defines a predicate used to filter results
  41166. * @returns an array of TransformNode
  41167. */
  41168. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41169. /**
  41170. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41171. * This allowed control for front to back rendering or reversly depending of the special needs.
  41172. *
  41173. * @param renderingGroupId The rendering group id corresponding to its index
  41174. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41175. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41176. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41177. */
  41178. 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;
  41179. /**
  41180. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41181. *
  41182. * @param renderingGroupId The rendering group id corresponding to its index
  41183. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41184. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41185. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41186. */
  41187. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41188. /**
  41189. * Gets the current auto clear configuration for one rendering group of the rendering
  41190. * manager.
  41191. * @param index the rendering group index to get the information for
  41192. * @returns The auto clear setup for the requested rendering group
  41193. */
  41194. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41195. private _blockMaterialDirtyMechanism;
  41196. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41197. get blockMaterialDirtyMechanism(): boolean;
  41198. set blockMaterialDirtyMechanism(value: boolean);
  41199. /**
  41200. * Will flag all materials as dirty to trigger new shader compilation
  41201. * @param flag defines the flag used to specify which material part must be marked as dirty
  41202. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41203. */
  41204. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41205. /** @hidden */
  41206. _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;
  41207. /** @hidden */
  41208. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41209. /** @hidden */
  41210. _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;
  41211. /** @hidden */
  41212. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41213. /** @hidden */
  41214. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41215. /** @hidden */
  41216. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41217. }
  41218. }
  41219. declare module BABYLON {
  41220. /**
  41221. * Set of assets to keep when moving a scene into an asset container.
  41222. */
  41223. export class KeepAssets extends AbstractScene {
  41224. }
  41225. /**
  41226. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41227. */
  41228. export class InstantiatedEntries {
  41229. /**
  41230. * List of new root nodes (eg. nodes with no parent)
  41231. */
  41232. rootNodes: TransformNode[];
  41233. /**
  41234. * List of new skeletons
  41235. */
  41236. skeletons: Skeleton[];
  41237. /**
  41238. * List of new animation groups
  41239. */
  41240. animationGroups: AnimationGroup[];
  41241. }
  41242. /**
  41243. * Container with a set of assets that can be added or removed from a scene.
  41244. */
  41245. export class AssetContainer extends AbstractScene {
  41246. private _wasAddedToScene;
  41247. /**
  41248. * The scene the AssetContainer belongs to.
  41249. */
  41250. scene: Scene;
  41251. /**
  41252. * Instantiates an AssetContainer.
  41253. * @param scene The scene the AssetContainer belongs to.
  41254. */
  41255. constructor(scene: Scene);
  41256. /**
  41257. * Instantiate or clone all meshes and add the new ones to the scene.
  41258. * Skeletons and animation groups will all be cloned
  41259. * @param nameFunction defines an optional function used to get new names for clones
  41260. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41261. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41262. */
  41263. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41264. /**
  41265. * Adds all the assets from the container to the scene.
  41266. */
  41267. addAllToScene(): void;
  41268. /**
  41269. * Removes all the assets in the container from the scene
  41270. */
  41271. removeAllFromScene(): void;
  41272. /**
  41273. * Disposes all the assets in the container
  41274. */
  41275. dispose(): void;
  41276. private _moveAssets;
  41277. /**
  41278. * Removes all the assets contained in the scene and adds them to the container.
  41279. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41280. */
  41281. moveAllFromScene(keepAssets?: KeepAssets): void;
  41282. /**
  41283. * 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.
  41284. * @returns the root mesh
  41285. */
  41286. createRootMesh(): Mesh;
  41287. /**
  41288. * Merge animations (direct and animation groups) from this asset container into a scene
  41289. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41290. * @param animatables set of animatables to retarget to a node from the scene
  41291. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41292. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41293. */
  41294. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41295. }
  41296. }
  41297. declare module BABYLON {
  41298. /**
  41299. * Defines how the parser contract is defined.
  41300. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41301. */
  41302. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41303. /**
  41304. * Defines how the individual parser contract is defined.
  41305. * These parser can parse an individual asset
  41306. */
  41307. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41308. /**
  41309. * Base class of the scene acting as a container for the different elements composing a scene.
  41310. * This class is dynamically extended by the different components of the scene increasing
  41311. * flexibility and reducing coupling
  41312. */
  41313. export abstract class AbstractScene {
  41314. /**
  41315. * Stores the list of available parsers in the application.
  41316. */
  41317. private static _BabylonFileParsers;
  41318. /**
  41319. * Stores the list of available individual parsers in the application.
  41320. */
  41321. private static _IndividualBabylonFileParsers;
  41322. /**
  41323. * Adds a parser in the list of available ones
  41324. * @param name Defines the name of the parser
  41325. * @param parser Defines the parser to add
  41326. */
  41327. static AddParser(name: string, parser: BabylonFileParser): void;
  41328. /**
  41329. * Gets a general parser from the list of avaialble ones
  41330. * @param name Defines the name of the parser
  41331. * @returns the requested parser or null
  41332. */
  41333. static GetParser(name: string): Nullable<BabylonFileParser>;
  41334. /**
  41335. * Adds n individual parser in the list of available ones
  41336. * @param name Defines the name of the parser
  41337. * @param parser Defines the parser to add
  41338. */
  41339. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41340. /**
  41341. * Gets an individual parser from the list of avaialble ones
  41342. * @param name Defines the name of the parser
  41343. * @returns the requested parser or null
  41344. */
  41345. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41346. /**
  41347. * Parser json data and populate both a scene and its associated container object
  41348. * @param jsonData Defines the data to parse
  41349. * @param scene Defines the scene to parse the data for
  41350. * @param container Defines the container attached to the parsing sequence
  41351. * @param rootUrl Defines the root url of the data
  41352. */
  41353. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41354. /**
  41355. * Gets the list of root nodes (ie. nodes with no parent)
  41356. */
  41357. rootNodes: Node[];
  41358. /** All of the cameras added to this scene
  41359. * @see https://doc.babylonjs.com/babylon101/cameras
  41360. */
  41361. cameras: Camera[];
  41362. /**
  41363. * All of the lights added to this scene
  41364. * @see https://doc.babylonjs.com/babylon101/lights
  41365. */
  41366. lights: Light[];
  41367. /**
  41368. * All of the (abstract) meshes added to this scene
  41369. */
  41370. meshes: AbstractMesh[];
  41371. /**
  41372. * The list of skeletons added to the scene
  41373. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41374. */
  41375. skeletons: Skeleton[];
  41376. /**
  41377. * All of the particle systems added to this scene
  41378. * @see https://doc.babylonjs.com/babylon101/particles
  41379. */
  41380. particleSystems: IParticleSystem[];
  41381. /**
  41382. * Gets a list of Animations associated with the scene
  41383. */
  41384. animations: Animation[];
  41385. /**
  41386. * All of the animation groups added to this scene
  41387. * @see https://doc.babylonjs.com/how_to/group
  41388. */
  41389. animationGroups: AnimationGroup[];
  41390. /**
  41391. * All of the multi-materials added to this scene
  41392. * @see https://doc.babylonjs.com/how_to/multi_materials
  41393. */
  41394. multiMaterials: MultiMaterial[];
  41395. /**
  41396. * All of the materials added to this scene
  41397. * In the context of a Scene, it is not supposed to be modified manually.
  41398. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41399. * Note also that the order of the Material within the array is not significant and might change.
  41400. * @see https://doc.babylonjs.com/babylon101/materials
  41401. */
  41402. materials: Material[];
  41403. /**
  41404. * The list of morph target managers added to the scene
  41405. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41406. */
  41407. morphTargetManagers: MorphTargetManager[];
  41408. /**
  41409. * The list of geometries used in the scene.
  41410. */
  41411. geometries: Geometry[];
  41412. /**
  41413. * All of the tranform nodes added to this scene
  41414. * In the context of a Scene, it is not supposed to be modified manually.
  41415. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41416. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41417. * @see https://doc.babylonjs.com/how_to/transformnode
  41418. */
  41419. transformNodes: TransformNode[];
  41420. /**
  41421. * ActionManagers available on the scene.
  41422. */
  41423. actionManagers: AbstractActionManager[];
  41424. /**
  41425. * Textures to keep.
  41426. */
  41427. textures: BaseTexture[];
  41428. /** @hidden */
  41429. protected _environmentTexture: Nullable<BaseTexture>;
  41430. /**
  41431. * Texture used in all pbr material as the reflection texture.
  41432. * As in the majority of the scene they are the same (exception for multi room and so on),
  41433. * this is easier to reference from here than from all the materials.
  41434. */
  41435. get environmentTexture(): Nullable<BaseTexture>;
  41436. set environmentTexture(value: Nullable<BaseTexture>);
  41437. /**
  41438. * The list of postprocesses added to the scene
  41439. */
  41440. postProcesses: PostProcess[];
  41441. /**
  41442. * @returns all meshes, lights, cameras, transformNodes and bones
  41443. */
  41444. getNodes(): Array<Node>;
  41445. }
  41446. }
  41447. declare module BABYLON {
  41448. /**
  41449. * Interface used to define options for Sound class
  41450. */
  41451. export interface ISoundOptions {
  41452. /**
  41453. * Does the sound autoplay once loaded.
  41454. */
  41455. autoplay?: boolean;
  41456. /**
  41457. * Does the sound loop after it finishes playing once.
  41458. */
  41459. loop?: boolean;
  41460. /**
  41461. * Sound's volume
  41462. */
  41463. volume?: number;
  41464. /**
  41465. * Is it a spatial sound?
  41466. */
  41467. spatialSound?: boolean;
  41468. /**
  41469. * Maximum distance to hear that sound
  41470. */
  41471. maxDistance?: number;
  41472. /**
  41473. * Uses user defined attenuation function
  41474. */
  41475. useCustomAttenuation?: boolean;
  41476. /**
  41477. * Define the roll off factor of spatial sounds.
  41478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41479. */
  41480. rolloffFactor?: number;
  41481. /**
  41482. * Define the reference distance the sound should be heard perfectly.
  41483. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41484. */
  41485. refDistance?: number;
  41486. /**
  41487. * Define the distance attenuation model the sound will follow.
  41488. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41489. */
  41490. distanceModel?: string;
  41491. /**
  41492. * Defines the playback speed (1 by default)
  41493. */
  41494. playbackRate?: number;
  41495. /**
  41496. * Defines if the sound is from a streaming source
  41497. */
  41498. streaming?: boolean;
  41499. /**
  41500. * Defines an optional length (in seconds) inside the sound file
  41501. */
  41502. length?: number;
  41503. /**
  41504. * Defines an optional offset (in seconds) inside the sound file
  41505. */
  41506. offset?: number;
  41507. /**
  41508. * If true, URLs will not be required to state the audio file codec to use.
  41509. */
  41510. skipCodecCheck?: boolean;
  41511. }
  41512. /**
  41513. * Defines a sound that can be played in the application.
  41514. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41516. */
  41517. export class Sound {
  41518. /**
  41519. * The name of the sound in the scene.
  41520. */
  41521. name: string;
  41522. /**
  41523. * Does the sound autoplay once loaded.
  41524. */
  41525. autoplay: boolean;
  41526. /**
  41527. * Does the sound loop after it finishes playing once.
  41528. */
  41529. loop: boolean;
  41530. /**
  41531. * Does the sound use a custom attenuation curve to simulate the falloff
  41532. * happening when the source gets further away from the camera.
  41533. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41534. */
  41535. useCustomAttenuation: boolean;
  41536. /**
  41537. * The sound track id this sound belongs to.
  41538. */
  41539. soundTrackId: number;
  41540. /**
  41541. * Is this sound currently played.
  41542. */
  41543. isPlaying: boolean;
  41544. /**
  41545. * Is this sound currently paused.
  41546. */
  41547. isPaused: boolean;
  41548. /**
  41549. * Does this sound enables spatial sound.
  41550. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41551. */
  41552. spatialSound: boolean;
  41553. /**
  41554. * Define the reference distance the sound should be heard perfectly.
  41555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41556. */
  41557. refDistance: number;
  41558. /**
  41559. * Define the roll off factor of spatial sounds.
  41560. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41561. */
  41562. rolloffFactor: number;
  41563. /**
  41564. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41565. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41566. */
  41567. maxDistance: number;
  41568. /**
  41569. * Define the distance attenuation model the sound will follow.
  41570. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41571. */
  41572. distanceModel: string;
  41573. /**
  41574. * @hidden
  41575. * Back Compat
  41576. **/
  41577. onended: () => any;
  41578. /**
  41579. * Gets or sets an object used to store user defined information for the sound.
  41580. */
  41581. metadata: any;
  41582. /**
  41583. * Observable event when the current playing sound finishes.
  41584. */
  41585. onEndedObservable: Observable<Sound>;
  41586. private _panningModel;
  41587. private _playbackRate;
  41588. private _streaming;
  41589. private _startTime;
  41590. private _startOffset;
  41591. private _position;
  41592. /** @hidden */
  41593. _positionInEmitterSpace: boolean;
  41594. private _localDirection;
  41595. private _volume;
  41596. private _isReadyToPlay;
  41597. private _isDirectional;
  41598. private _readyToPlayCallback;
  41599. private _audioBuffer;
  41600. private _soundSource;
  41601. private _streamingSource;
  41602. private _soundPanner;
  41603. private _soundGain;
  41604. private _inputAudioNode;
  41605. private _outputAudioNode;
  41606. private _coneInnerAngle;
  41607. private _coneOuterAngle;
  41608. private _coneOuterGain;
  41609. private _scene;
  41610. private _connectedTransformNode;
  41611. private _customAttenuationFunction;
  41612. private _registerFunc;
  41613. private _isOutputConnected;
  41614. private _htmlAudioElement;
  41615. private _urlType;
  41616. private _length?;
  41617. private _offset?;
  41618. /** @hidden */
  41619. static _SceneComponentInitialization: (scene: Scene) => void;
  41620. /**
  41621. * Create a sound and attach it to a scene
  41622. * @param name Name of your sound
  41623. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41624. * @param scene defines the scene the sound belongs to
  41625. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41626. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41627. */
  41628. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41629. /**
  41630. * Release the sound and its associated resources
  41631. */
  41632. dispose(): void;
  41633. /**
  41634. * Gets if the sounds is ready to be played or not.
  41635. * @returns true if ready, otherwise false
  41636. */
  41637. isReady(): boolean;
  41638. private _soundLoaded;
  41639. /**
  41640. * Sets the data of the sound from an audiobuffer
  41641. * @param audioBuffer The audioBuffer containing the data
  41642. */
  41643. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41644. /**
  41645. * Updates the current sounds options such as maxdistance, loop...
  41646. * @param options A JSON object containing values named as the object properties
  41647. */
  41648. updateOptions(options: ISoundOptions): void;
  41649. private _createSpatialParameters;
  41650. private _updateSpatialParameters;
  41651. /**
  41652. * Switch the panning model to HRTF:
  41653. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41654. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41655. */
  41656. switchPanningModelToHRTF(): void;
  41657. /**
  41658. * Switch the panning model to Equal Power:
  41659. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41660. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41661. */
  41662. switchPanningModelToEqualPower(): void;
  41663. private _switchPanningModel;
  41664. /**
  41665. * Connect this sound to a sound track audio node like gain...
  41666. * @param soundTrackAudioNode the sound track audio node to connect to
  41667. */
  41668. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41669. /**
  41670. * Transform this sound into a directional source
  41671. * @param coneInnerAngle Size of the inner cone in degree
  41672. * @param coneOuterAngle Size of the outer cone in degree
  41673. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41674. */
  41675. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41676. /**
  41677. * Gets or sets the inner angle for the directional cone.
  41678. */
  41679. get directionalConeInnerAngle(): number;
  41680. /**
  41681. * Gets or sets the inner angle for the directional cone.
  41682. */
  41683. set directionalConeInnerAngle(value: number);
  41684. /**
  41685. * Gets or sets the outer angle for the directional cone.
  41686. */
  41687. get directionalConeOuterAngle(): number;
  41688. /**
  41689. * Gets or sets the outer angle for the directional cone.
  41690. */
  41691. set directionalConeOuterAngle(value: number);
  41692. /**
  41693. * Sets the position of the emitter if spatial sound is enabled
  41694. * @param newPosition Defines the new posisiton
  41695. */
  41696. setPosition(newPosition: Vector3): void;
  41697. /**
  41698. * Sets the local direction of the emitter if spatial sound is enabled
  41699. * @param newLocalDirection Defines the new local direction
  41700. */
  41701. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41702. private _updateDirection;
  41703. /** @hidden */
  41704. updateDistanceFromListener(): void;
  41705. /**
  41706. * Sets a new custom attenuation function for the sound.
  41707. * @param callback Defines the function used for the attenuation
  41708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41709. */
  41710. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41711. /**
  41712. * Play the sound
  41713. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41714. * @param offset (optional) Start the sound at a specific time in seconds
  41715. * @param length (optional) Sound duration (in seconds)
  41716. */
  41717. play(time?: number, offset?: number, length?: number): void;
  41718. private _onended;
  41719. /**
  41720. * Stop the sound
  41721. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41722. */
  41723. stop(time?: number): void;
  41724. /**
  41725. * Put the sound in pause
  41726. */
  41727. pause(): void;
  41728. /**
  41729. * Sets a dedicated volume for this sounds
  41730. * @param newVolume Define the new volume of the sound
  41731. * @param time Define time for gradual change to new volume
  41732. */
  41733. setVolume(newVolume: number, time?: number): void;
  41734. /**
  41735. * Set the sound play back rate
  41736. * @param newPlaybackRate Define the playback rate the sound should be played at
  41737. */
  41738. setPlaybackRate(newPlaybackRate: number): void;
  41739. /**
  41740. * Gets the volume of the sound.
  41741. * @returns the volume of the sound
  41742. */
  41743. getVolume(): number;
  41744. /**
  41745. * Attach the sound to a dedicated mesh
  41746. * @param transformNode The transform node to connect the sound with
  41747. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41748. */
  41749. attachToMesh(transformNode: TransformNode): void;
  41750. /**
  41751. * Detach the sound from the previously attached mesh
  41752. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41753. */
  41754. detachFromMesh(): void;
  41755. private _onRegisterAfterWorldMatrixUpdate;
  41756. /**
  41757. * Clone the current sound in the scene.
  41758. * @returns the new sound clone
  41759. */
  41760. clone(): Nullable<Sound>;
  41761. /**
  41762. * Gets the current underlying audio buffer containing the data
  41763. * @returns the audio buffer
  41764. */
  41765. getAudioBuffer(): Nullable<AudioBuffer>;
  41766. /**
  41767. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41768. * @returns the source node
  41769. */
  41770. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41771. /**
  41772. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41773. * @returns the gain node
  41774. */
  41775. getSoundGain(): Nullable<GainNode>;
  41776. /**
  41777. * Serializes the Sound in a JSON representation
  41778. * @returns the JSON representation of the sound
  41779. */
  41780. serialize(): any;
  41781. /**
  41782. * Parse a JSON representation of a sound to innstantiate in a given scene
  41783. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41784. * @param scene Define the scene the new parsed sound should be created in
  41785. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41786. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41787. * @returns the newly parsed sound
  41788. */
  41789. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41790. }
  41791. }
  41792. declare module BABYLON {
  41793. /**
  41794. * This defines an action helpful to play a defined sound on a triggered action.
  41795. */
  41796. export class PlaySoundAction extends Action {
  41797. private _sound;
  41798. /**
  41799. * Instantiate the action
  41800. * @param triggerOptions defines the trigger options
  41801. * @param sound defines the sound to play
  41802. * @param condition defines the trigger related conditions
  41803. */
  41804. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41805. /** @hidden */
  41806. _prepare(): void;
  41807. /**
  41808. * Execute the action and play the sound.
  41809. */
  41810. execute(): void;
  41811. /**
  41812. * Serializes the actions and its related information.
  41813. * @param parent defines the object to serialize in
  41814. * @returns the serialized object
  41815. */
  41816. serialize(parent: any): any;
  41817. }
  41818. /**
  41819. * This defines an action helpful to stop a defined sound on a triggered action.
  41820. */
  41821. export class StopSoundAction extends Action {
  41822. private _sound;
  41823. /**
  41824. * Instantiate the action
  41825. * @param triggerOptions defines the trigger options
  41826. * @param sound defines the sound to stop
  41827. * @param condition defines the trigger related conditions
  41828. */
  41829. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41830. /** @hidden */
  41831. _prepare(): void;
  41832. /**
  41833. * Execute the action and stop the sound.
  41834. */
  41835. execute(): void;
  41836. /**
  41837. * Serializes the actions and its related information.
  41838. * @param parent defines the object to serialize in
  41839. * @returns the serialized object
  41840. */
  41841. serialize(parent: any): any;
  41842. }
  41843. }
  41844. declare module BABYLON {
  41845. /**
  41846. * This defines an action responsible to change the value of a property
  41847. * by interpolating between its current value and the newly set one once triggered.
  41848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41849. */
  41850. export class InterpolateValueAction extends Action {
  41851. /**
  41852. * Defines the path of the property where the value should be interpolated
  41853. */
  41854. propertyPath: string;
  41855. /**
  41856. * Defines the target value at the end of the interpolation.
  41857. */
  41858. value: any;
  41859. /**
  41860. * Defines the time it will take for the property to interpolate to the value.
  41861. */
  41862. duration: number;
  41863. /**
  41864. * Defines if the other scene animations should be stopped when the action has been triggered
  41865. */
  41866. stopOtherAnimations?: boolean;
  41867. /**
  41868. * Defines a callback raised once the interpolation animation has been done.
  41869. */
  41870. onInterpolationDone?: () => void;
  41871. /**
  41872. * Observable triggered once the interpolation animation has been done.
  41873. */
  41874. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41875. private _target;
  41876. private _effectiveTarget;
  41877. private _property;
  41878. /**
  41879. * Instantiate the action
  41880. * @param triggerOptions defines the trigger options
  41881. * @param target defines the object containing the value to interpolate
  41882. * @param propertyPath defines the path to the property in the target object
  41883. * @param value defines the target value at the end of the interpolation
  41884. * @param duration deines the time it will take for the property to interpolate to the value.
  41885. * @param condition defines the trigger related conditions
  41886. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41887. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41888. */
  41889. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41890. /** @hidden */
  41891. _prepare(): void;
  41892. /**
  41893. * Execute the action starts the value interpolation.
  41894. */
  41895. execute(): void;
  41896. /**
  41897. * Serializes the actions and its related information.
  41898. * @param parent defines the object to serialize in
  41899. * @returns the serialized object
  41900. */
  41901. serialize(parent: any): any;
  41902. }
  41903. }
  41904. declare module BABYLON {
  41905. /**
  41906. * Options allowed during the creation of a sound track.
  41907. */
  41908. export interface ISoundTrackOptions {
  41909. /**
  41910. * The volume the sound track should take during creation
  41911. */
  41912. volume?: number;
  41913. /**
  41914. * Define if the sound track is the main sound track of the scene
  41915. */
  41916. mainTrack?: boolean;
  41917. }
  41918. /**
  41919. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41920. * It will be also used in a future release to apply effects on a specific track.
  41921. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41922. */
  41923. export class SoundTrack {
  41924. /**
  41925. * The unique identifier of the sound track in the scene.
  41926. */
  41927. id: number;
  41928. /**
  41929. * The list of sounds included in the sound track.
  41930. */
  41931. soundCollection: Array<Sound>;
  41932. private _outputAudioNode;
  41933. private _scene;
  41934. private _connectedAnalyser;
  41935. private _options;
  41936. private _isInitialized;
  41937. /**
  41938. * Creates a new sound track.
  41939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41940. * @param scene Define the scene the sound track belongs to
  41941. * @param options
  41942. */
  41943. constructor(scene: Scene, options?: ISoundTrackOptions);
  41944. private _initializeSoundTrackAudioGraph;
  41945. /**
  41946. * Release the sound track and its associated resources
  41947. */
  41948. dispose(): void;
  41949. /**
  41950. * Adds a sound to this sound track
  41951. * @param sound define the cound to add
  41952. * @ignoreNaming
  41953. */
  41954. AddSound(sound: Sound): void;
  41955. /**
  41956. * Removes a sound to this sound track
  41957. * @param sound define the cound to remove
  41958. * @ignoreNaming
  41959. */
  41960. RemoveSound(sound: Sound): void;
  41961. /**
  41962. * Set a global volume for the full sound track.
  41963. * @param newVolume Define the new volume of the sound track
  41964. */
  41965. setVolume(newVolume: number): void;
  41966. /**
  41967. * Switch the panning model to HRTF:
  41968. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41970. */
  41971. switchPanningModelToHRTF(): void;
  41972. /**
  41973. * Switch the panning model to Equal Power:
  41974. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41976. */
  41977. switchPanningModelToEqualPower(): void;
  41978. /**
  41979. * Connect the sound track to an audio analyser allowing some amazing
  41980. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41981. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41982. * @param analyser The analyser to connect to the engine
  41983. */
  41984. connectToAnalyser(analyser: Analyser): void;
  41985. }
  41986. }
  41987. declare module BABYLON {
  41988. interface AbstractScene {
  41989. /**
  41990. * The list of sounds used in the scene.
  41991. */
  41992. sounds: Nullable<Array<Sound>>;
  41993. }
  41994. interface Scene {
  41995. /**
  41996. * @hidden
  41997. * Backing field
  41998. */
  41999. _mainSoundTrack: SoundTrack;
  42000. /**
  42001. * The main sound track played by the scene.
  42002. * It cotains your primary collection of sounds.
  42003. */
  42004. mainSoundTrack: SoundTrack;
  42005. /**
  42006. * The list of sound tracks added to the scene
  42007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42008. */
  42009. soundTracks: Nullable<Array<SoundTrack>>;
  42010. /**
  42011. * Gets a sound using a given name
  42012. * @param name defines the name to search for
  42013. * @return the found sound or null if not found at all.
  42014. */
  42015. getSoundByName(name: string): Nullable<Sound>;
  42016. /**
  42017. * Gets or sets if audio support is enabled
  42018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42019. */
  42020. audioEnabled: boolean;
  42021. /**
  42022. * Gets or sets if audio will be output to headphones
  42023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42024. */
  42025. headphone: boolean;
  42026. /**
  42027. * Gets or sets custom audio listener position provider
  42028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42029. */
  42030. audioListenerPositionProvider: Nullable<() => Vector3>;
  42031. /**
  42032. * Gets or sets a refresh rate when using 3D audio positioning
  42033. */
  42034. audioPositioningRefreshRate: number;
  42035. }
  42036. /**
  42037. * Defines the sound scene component responsible to manage any sounds
  42038. * in a given scene.
  42039. */
  42040. export class AudioSceneComponent implements ISceneSerializableComponent {
  42041. private static _CameraDirectionLH;
  42042. private static _CameraDirectionRH;
  42043. /**
  42044. * The component name helpfull to identify the component in the list of scene components.
  42045. */
  42046. readonly name: string;
  42047. /**
  42048. * The scene the component belongs to.
  42049. */
  42050. scene: Scene;
  42051. private _audioEnabled;
  42052. /**
  42053. * Gets whether audio is enabled or not.
  42054. * Please use related enable/disable method to switch state.
  42055. */
  42056. get audioEnabled(): boolean;
  42057. private _headphone;
  42058. /**
  42059. * Gets whether audio is outputing to headphone or not.
  42060. * Please use the according Switch methods to change output.
  42061. */
  42062. get headphone(): boolean;
  42063. /**
  42064. * Gets or sets a refresh rate when using 3D audio positioning
  42065. */
  42066. audioPositioningRefreshRate: number;
  42067. private _audioListenerPositionProvider;
  42068. /**
  42069. * Gets the current audio listener position provider
  42070. */
  42071. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42072. /**
  42073. * Sets a custom listener position for all sounds in the scene
  42074. * By default, this is the position of the first active camera
  42075. */
  42076. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42077. /**
  42078. * Creates a new instance of the component for the given scene
  42079. * @param scene Defines the scene to register the component in
  42080. */
  42081. constructor(scene: Scene);
  42082. /**
  42083. * Registers the component in a given scene
  42084. */
  42085. register(): void;
  42086. /**
  42087. * Rebuilds the elements related to this component in case of
  42088. * context lost for instance.
  42089. */
  42090. rebuild(): void;
  42091. /**
  42092. * Serializes the component data to the specified json object
  42093. * @param serializationObject The object to serialize to
  42094. */
  42095. serialize(serializationObject: any): void;
  42096. /**
  42097. * Adds all the elements from the container to the scene
  42098. * @param container the container holding the elements
  42099. */
  42100. addFromContainer(container: AbstractScene): void;
  42101. /**
  42102. * Removes all the elements in the container from the scene
  42103. * @param container contains the elements to remove
  42104. * @param dispose if the removed element should be disposed (default: false)
  42105. */
  42106. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42107. /**
  42108. * Disposes the component and the associated ressources.
  42109. */
  42110. dispose(): void;
  42111. /**
  42112. * Disables audio in the associated scene.
  42113. */
  42114. disableAudio(): void;
  42115. /**
  42116. * Enables audio in the associated scene.
  42117. */
  42118. enableAudio(): void;
  42119. /**
  42120. * Switch audio to headphone output.
  42121. */
  42122. switchAudioModeForHeadphones(): void;
  42123. /**
  42124. * Switch audio to normal speakers.
  42125. */
  42126. switchAudioModeForNormalSpeakers(): void;
  42127. private _cachedCameraDirection;
  42128. private _cachedCameraPosition;
  42129. private _lastCheck;
  42130. private _afterRender;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /**
  42135. * Wraps one or more Sound objects and selects one with random weight for playback.
  42136. */
  42137. export class WeightedSound {
  42138. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42139. loop: boolean;
  42140. private _coneInnerAngle;
  42141. private _coneOuterAngle;
  42142. private _volume;
  42143. /** A Sound is currently playing. */
  42144. isPlaying: boolean;
  42145. /** A Sound is currently paused. */
  42146. isPaused: boolean;
  42147. private _sounds;
  42148. private _weights;
  42149. private _currentIndex?;
  42150. /**
  42151. * Creates a new WeightedSound from the list of sounds given.
  42152. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42153. * @param sounds Array of Sounds that will be selected from.
  42154. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42155. */
  42156. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42157. /**
  42158. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42159. */
  42160. get directionalConeInnerAngle(): number;
  42161. /**
  42162. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42163. */
  42164. set directionalConeInnerAngle(value: number);
  42165. /**
  42166. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42167. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42168. */
  42169. get directionalConeOuterAngle(): number;
  42170. /**
  42171. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42172. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42173. */
  42174. set directionalConeOuterAngle(value: number);
  42175. /**
  42176. * Playback volume.
  42177. */
  42178. get volume(): number;
  42179. /**
  42180. * Playback volume.
  42181. */
  42182. set volume(value: number);
  42183. private _onended;
  42184. /**
  42185. * Suspend playback
  42186. */
  42187. pause(): void;
  42188. /**
  42189. * Stop playback
  42190. */
  42191. stop(): void;
  42192. /**
  42193. * Start playback.
  42194. * @param startOffset Position the clip head at a specific time in seconds.
  42195. */
  42196. play(startOffset?: number): void;
  42197. }
  42198. }
  42199. declare module BABYLON {
  42200. /**
  42201. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42202. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42203. */
  42204. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42205. /**
  42206. * Gets the name of the behavior.
  42207. */
  42208. get name(): string;
  42209. /**
  42210. * The easing function used by animations
  42211. */
  42212. static EasingFunction: BackEase;
  42213. /**
  42214. * The easing mode used by animations
  42215. */
  42216. static EasingMode: number;
  42217. /**
  42218. * The duration of the animation, in milliseconds
  42219. */
  42220. transitionDuration: number;
  42221. /**
  42222. * Length of the distance animated by the transition when lower radius is reached
  42223. */
  42224. lowerRadiusTransitionRange: number;
  42225. /**
  42226. * Length of the distance animated by the transition when upper radius is reached
  42227. */
  42228. upperRadiusTransitionRange: number;
  42229. private _autoTransitionRange;
  42230. /**
  42231. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42232. */
  42233. get autoTransitionRange(): boolean;
  42234. /**
  42235. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42236. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42237. */
  42238. set autoTransitionRange(value: boolean);
  42239. private _attachedCamera;
  42240. private _onAfterCheckInputsObserver;
  42241. private _onMeshTargetChangedObserver;
  42242. /**
  42243. * Initializes the behavior.
  42244. */
  42245. init(): void;
  42246. /**
  42247. * Attaches the behavior to its arc rotate camera.
  42248. * @param camera Defines the camera to attach the behavior to
  42249. */
  42250. attach(camera: ArcRotateCamera): void;
  42251. /**
  42252. * Detaches the behavior from its current arc rotate camera.
  42253. */
  42254. detach(): void;
  42255. private _radiusIsAnimating;
  42256. private _radiusBounceTransition;
  42257. private _animatables;
  42258. private _cachedWheelPrecision;
  42259. /**
  42260. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42261. * @param radiusLimit The limit to check against.
  42262. * @return Bool to indicate if at limit.
  42263. */
  42264. private _isRadiusAtLimit;
  42265. /**
  42266. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42267. * @param radiusDelta The delta by which to animate to. Can be negative.
  42268. */
  42269. private _applyBoundRadiusAnimation;
  42270. /**
  42271. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42272. */
  42273. protected _clearAnimationLocks(): void;
  42274. /**
  42275. * Stops and removes all animations that have been applied to the camera
  42276. */
  42277. stopAllAnimations(): void;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * 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.
  42283. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42284. */
  42285. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42286. /**
  42287. * Gets the name of the behavior.
  42288. */
  42289. get name(): string;
  42290. private _mode;
  42291. private _radiusScale;
  42292. private _positionScale;
  42293. private _defaultElevation;
  42294. private _elevationReturnTime;
  42295. private _elevationReturnWaitTime;
  42296. private _zoomStopsAnimation;
  42297. private _framingTime;
  42298. /**
  42299. * The easing function used by animations
  42300. */
  42301. static EasingFunction: ExponentialEase;
  42302. /**
  42303. * The easing mode used by animations
  42304. */
  42305. static EasingMode: number;
  42306. /**
  42307. * Sets the current mode used by the behavior
  42308. */
  42309. set mode(mode: number);
  42310. /**
  42311. * Gets current mode used by the behavior.
  42312. */
  42313. get mode(): number;
  42314. /**
  42315. * Sets the scale applied to the radius (1 by default)
  42316. */
  42317. set radiusScale(radius: number);
  42318. /**
  42319. * Gets the scale applied to the radius
  42320. */
  42321. get radiusScale(): number;
  42322. /**
  42323. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42324. */
  42325. set positionScale(scale: number);
  42326. /**
  42327. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42328. */
  42329. get positionScale(): number;
  42330. /**
  42331. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42332. * behaviour is triggered, in radians.
  42333. */
  42334. set defaultElevation(elevation: number);
  42335. /**
  42336. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42337. * behaviour is triggered, in radians.
  42338. */
  42339. get defaultElevation(): number;
  42340. /**
  42341. * Sets the time (in milliseconds) taken to return to the default beta position.
  42342. * Negative value indicates camera should not return to default.
  42343. */
  42344. set elevationReturnTime(speed: number);
  42345. /**
  42346. * Gets the time (in milliseconds) taken to return to the default beta position.
  42347. * Negative value indicates camera should not return to default.
  42348. */
  42349. get elevationReturnTime(): number;
  42350. /**
  42351. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42352. */
  42353. set elevationReturnWaitTime(time: number);
  42354. /**
  42355. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42356. */
  42357. get elevationReturnWaitTime(): number;
  42358. /**
  42359. * Sets the flag that indicates if user zooming should stop animation.
  42360. */
  42361. set zoomStopsAnimation(flag: boolean);
  42362. /**
  42363. * Gets the flag that indicates if user zooming should stop animation.
  42364. */
  42365. get zoomStopsAnimation(): boolean;
  42366. /**
  42367. * Sets the transition time when framing the mesh, in milliseconds
  42368. */
  42369. set framingTime(time: number);
  42370. /**
  42371. * Gets the transition time when framing the mesh, in milliseconds
  42372. */
  42373. get framingTime(): number;
  42374. /**
  42375. * Define if the behavior should automatically change the configured
  42376. * camera limits and sensibilities.
  42377. */
  42378. autoCorrectCameraLimitsAndSensibility: boolean;
  42379. private _onPrePointerObservableObserver;
  42380. private _onAfterCheckInputsObserver;
  42381. private _onMeshTargetChangedObserver;
  42382. private _attachedCamera;
  42383. private _isPointerDown;
  42384. private _lastInteractionTime;
  42385. /**
  42386. * Initializes the behavior.
  42387. */
  42388. init(): void;
  42389. /**
  42390. * Attaches the behavior to its arc rotate camera.
  42391. * @param camera Defines the camera to attach the behavior to
  42392. */
  42393. attach(camera: ArcRotateCamera): void;
  42394. /**
  42395. * Detaches the behavior from its current arc rotate camera.
  42396. */
  42397. detach(): void;
  42398. private _animatables;
  42399. private _betaIsAnimating;
  42400. private _betaTransition;
  42401. private _radiusTransition;
  42402. private _vectorTransition;
  42403. /**
  42404. * Targets the given mesh and updates zoom level accordingly.
  42405. * @param mesh The mesh to target.
  42406. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42407. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42408. */
  42409. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42410. /**
  42411. * Targets the given mesh with its children and updates zoom level accordingly.
  42412. * @param mesh The mesh to target.
  42413. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42414. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42415. */
  42416. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42417. /**
  42418. * Targets the given meshes with their children and updates zoom level accordingly.
  42419. * @param meshes The mesh to target.
  42420. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42421. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42422. */
  42423. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42424. /**
  42425. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42426. * @param minimumWorld Determines the smaller position of the bounding box extend
  42427. * @param maximumWorld Determines the bigger position of the bounding box extend
  42428. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42429. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42430. */
  42431. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42432. /**
  42433. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42434. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42435. * frustum width.
  42436. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42437. * to fully enclose the mesh in the viewing frustum.
  42438. */
  42439. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42440. /**
  42441. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42442. * is automatically returned to its default position (expected to be above ground plane).
  42443. */
  42444. private _maintainCameraAboveGround;
  42445. /**
  42446. * Returns the frustum slope based on the canvas ratio and camera FOV
  42447. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42448. */
  42449. private _getFrustumSlope;
  42450. /**
  42451. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42452. */
  42453. private _clearAnimationLocks;
  42454. /**
  42455. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42456. */
  42457. private _applyUserInteraction;
  42458. /**
  42459. * Stops and removes all animations that have been applied to the camera
  42460. */
  42461. stopAllAnimations(): void;
  42462. /**
  42463. * Gets a value indicating if the user is moving the camera
  42464. */
  42465. get isUserIsMoving(): boolean;
  42466. /**
  42467. * The camera can move all the way towards the mesh.
  42468. */
  42469. static IgnoreBoundsSizeMode: number;
  42470. /**
  42471. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42472. */
  42473. static FitFrustumSidesMode: number;
  42474. }
  42475. }
  42476. declare module BABYLON {
  42477. /**
  42478. * Base class for Camera Pointer Inputs.
  42479. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42480. * for example usage.
  42481. */
  42482. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42483. /**
  42484. * Defines the camera the input is attached to.
  42485. */
  42486. abstract camera: Camera;
  42487. /**
  42488. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42489. */
  42490. protected _altKey: boolean;
  42491. protected _ctrlKey: boolean;
  42492. protected _metaKey: boolean;
  42493. protected _shiftKey: boolean;
  42494. /**
  42495. * Which mouse buttons were pressed at time of last mouse event.
  42496. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42497. */
  42498. protected _buttonsPressed: number;
  42499. /**
  42500. * Defines the buttons associated with the input to handle camera move.
  42501. */
  42502. buttons: number[];
  42503. /**
  42504. * Attach the input controls to a specific dom element to get the input from.
  42505. * @param element Defines the element the controls should be listened from
  42506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42507. */
  42508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42509. /**
  42510. * Detach the current controls from the specified dom element.
  42511. * @param element Defines the element to stop listening the inputs from
  42512. */
  42513. detachControl(element: Nullable<HTMLElement>): void;
  42514. /**
  42515. * Gets the class name of the current input.
  42516. * @returns the class name
  42517. */
  42518. getClassName(): string;
  42519. /**
  42520. * Get the friendly name associated with the input class.
  42521. * @returns the input friendly name
  42522. */
  42523. getSimpleName(): string;
  42524. /**
  42525. * Called on pointer POINTERDOUBLETAP event.
  42526. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42527. */
  42528. protected onDoubleTap(type: string): void;
  42529. /**
  42530. * Called on pointer POINTERMOVE event if only a single touch is active.
  42531. * Override this method to provide functionality.
  42532. */
  42533. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42534. /**
  42535. * Called on pointer POINTERMOVE event if multiple touches are active.
  42536. * Override this method to provide functionality.
  42537. */
  42538. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42539. /**
  42540. * Called on JS contextmenu event.
  42541. * Override this method to provide functionality.
  42542. */
  42543. protected onContextMenu(evt: PointerEvent): void;
  42544. /**
  42545. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42546. * press.
  42547. * Override this method to provide functionality.
  42548. */
  42549. protected onButtonDown(evt: PointerEvent): void;
  42550. /**
  42551. * Called each time a new POINTERUP event occurs. Ie, for each button
  42552. * release.
  42553. * Override this method to provide functionality.
  42554. */
  42555. protected onButtonUp(evt: PointerEvent): void;
  42556. /**
  42557. * Called when window becomes inactive.
  42558. * Override this method to provide functionality.
  42559. */
  42560. protected onLostFocus(): void;
  42561. private _pointerInput;
  42562. private _observer;
  42563. private _onLostFocus;
  42564. private pointA;
  42565. private pointB;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Manage the pointers inputs to control an arc rotate camera.
  42571. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42572. */
  42573. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42574. /**
  42575. * Defines the camera the input is attached to.
  42576. */
  42577. camera: ArcRotateCamera;
  42578. /**
  42579. * Gets the class name of the current input.
  42580. * @returns the class name
  42581. */
  42582. getClassName(): string;
  42583. /**
  42584. * Defines the buttons associated with the input to handle camera move.
  42585. */
  42586. buttons: number[];
  42587. /**
  42588. * Defines the pointer angular sensibility along the X axis or how fast is
  42589. * the camera rotating.
  42590. */
  42591. angularSensibilityX: number;
  42592. /**
  42593. * Defines the pointer angular sensibility along the Y axis or how fast is
  42594. * the camera rotating.
  42595. */
  42596. angularSensibilityY: number;
  42597. /**
  42598. * Defines the pointer pinch precision or how fast is the camera zooming.
  42599. */
  42600. pinchPrecision: number;
  42601. /**
  42602. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42603. * from 0.
  42604. * It defines the percentage of current camera.radius to use as delta when
  42605. * pinch zoom is used.
  42606. */
  42607. pinchDeltaPercentage: number;
  42608. /**
  42609. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42610. * that any object in the plane at the camera's target point will scale
  42611. * perfectly with finger motion.
  42612. * Overrides pinchDeltaPercentage and pinchPrecision.
  42613. */
  42614. useNaturalPinchZoom: boolean;
  42615. /**
  42616. * Defines the pointer panning sensibility or how fast is the camera moving.
  42617. */
  42618. panningSensibility: number;
  42619. /**
  42620. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42621. */
  42622. multiTouchPanning: boolean;
  42623. /**
  42624. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42625. * zoom (pinch) through multitouch.
  42626. */
  42627. multiTouchPanAndZoom: boolean;
  42628. /**
  42629. * Revers pinch action direction.
  42630. */
  42631. pinchInwards: boolean;
  42632. private _isPanClick;
  42633. private _twoFingerActivityCount;
  42634. private _isPinching;
  42635. /**
  42636. * Called on pointer POINTERMOVE event if only a single touch is active.
  42637. */
  42638. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42639. /**
  42640. * Called on pointer POINTERDOUBLETAP event.
  42641. */
  42642. protected onDoubleTap(type: string): void;
  42643. /**
  42644. * Called on pointer POINTERMOVE event if multiple touches are active.
  42645. */
  42646. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42647. /**
  42648. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42649. * press.
  42650. */
  42651. protected onButtonDown(evt: PointerEvent): void;
  42652. /**
  42653. * Called each time a new POINTERUP event occurs. Ie, for each button
  42654. * release.
  42655. */
  42656. protected onButtonUp(evt: PointerEvent): void;
  42657. /**
  42658. * Called when window becomes inactive.
  42659. */
  42660. protected onLostFocus(): void;
  42661. }
  42662. }
  42663. declare module BABYLON {
  42664. /**
  42665. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42666. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42667. */
  42668. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42669. /**
  42670. * Defines the camera the input is attached to.
  42671. */
  42672. camera: ArcRotateCamera;
  42673. /**
  42674. * Defines the list of key codes associated with the up action (increase alpha)
  42675. */
  42676. keysUp: number[];
  42677. /**
  42678. * Defines the list of key codes associated with the down action (decrease alpha)
  42679. */
  42680. keysDown: number[];
  42681. /**
  42682. * Defines the list of key codes associated with the left action (increase beta)
  42683. */
  42684. keysLeft: number[];
  42685. /**
  42686. * Defines the list of key codes associated with the right action (decrease beta)
  42687. */
  42688. keysRight: number[];
  42689. /**
  42690. * Defines the list of key codes associated with the reset action.
  42691. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42692. */
  42693. keysReset: number[];
  42694. /**
  42695. * Defines the panning sensibility of the inputs.
  42696. * (How fast is the camera panning)
  42697. */
  42698. panningSensibility: number;
  42699. /**
  42700. * Defines the zooming sensibility of the inputs.
  42701. * (How fast is the camera zooming)
  42702. */
  42703. zoomingSensibility: number;
  42704. /**
  42705. * Defines whether maintaining the alt key down switch the movement mode from
  42706. * orientation to zoom.
  42707. */
  42708. useAltToZoom: boolean;
  42709. /**
  42710. * Rotation speed of the camera
  42711. */
  42712. angularSpeed: number;
  42713. private _keys;
  42714. private _ctrlPressed;
  42715. private _altPressed;
  42716. private _onCanvasBlurObserver;
  42717. private _onKeyboardObserver;
  42718. private _engine;
  42719. private _scene;
  42720. /**
  42721. * Attach the input controls to a specific dom element to get the input from.
  42722. * @param element Defines the element the controls should be listened from
  42723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42724. */
  42725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42726. /**
  42727. * Detach the current controls from the specified dom element.
  42728. * @param element Defines the element to stop listening the inputs from
  42729. */
  42730. detachControl(element: Nullable<HTMLElement>): void;
  42731. /**
  42732. * Update the current camera state depending on the inputs that have been used this frame.
  42733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42734. */
  42735. checkInputs(): void;
  42736. /**
  42737. * Gets the class name of the current intput.
  42738. * @returns the class name
  42739. */
  42740. getClassName(): string;
  42741. /**
  42742. * Get the friendly name associated with the input class.
  42743. * @returns the input friendly name
  42744. */
  42745. getSimpleName(): string;
  42746. }
  42747. }
  42748. declare module BABYLON {
  42749. /**
  42750. * Manage the mouse wheel inputs to control an arc rotate camera.
  42751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42752. */
  42753. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42754. /**
  42755. * Defines the camera the input is attached to.
  42756. */
  42757. camera: ArcRotateCamera;
  42758. /**
  42759. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42760. */
  42761. wheelPrecision: number;
  42762. /**
  42763. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42764. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42765. */
  42766. wheelDeltaPercentage: number;
  42767. private _wheel;
  42768. private _observer;
  42769. private computeDeltaFromMouseWheelLegacyEvent;
  42770. /**
  42771. * Attach the input controls to a specific dom element to get the input from.
  42772. * @param element Defines the element the controls should be listened from
  42773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42774. */
  42775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42776. /**
  42777. * Detach the current controls from the specified dom element.
  42778. * @param element Defines the element to stop listening the inputs from
  42779. */
  42780. detachControl(element: Nullable<HTMLElement>): void;
  42781. /**
  42782. * Gets the class name of the current intput.
  42783. * @returns the class name
  42784. */
  42785. getClassName(): string;
  42786. /**
  42787. * Get the friendly name associated with the input class.
  42788. * @returns the input friendly name
  42789. */
  42790. getSimpleName(): string;
  42791. }
  42792. }
  42793. declare module BABYLON {
  42794. /**
  42795. * Default Inputs manager for the ArcRotateCamera.
  42796. * It groups all the default supported inputs for ease of use.
  42797. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42798. */
  42799. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42800. /**
  42801. * Instantiates a new ArcRotateCameraInputsManager.
  42802. * @param camera Defines the camera the inputs belong to
  42803. */
  42804. constructor(camera: ArcRotateCamera);
  42805. /**
  42806. * Add mouse wheel input support to the input manager.
  42807. * @returns the current input manager
  42808. */
  42809. addMouseWheel(): ArcRotateCameraInputsManager;
  42810. /**
  42811. * Add pointers input support to the input manager.
  42812. * @returns the current input manager
  42813. */
  42814. addPointers(): ArcRotateCameraInputsManager;
  42815. /**
  42816. * Add keyboard input support to the input manager.
  42817. * @returns the current input manager
  42818. */
  42819. addKeyboard(): ArcRotateCameraInputsManager;
  42820. }
  42821. }
  42822. declare module BABYLON {
  42823. /**
  42824. * This represents an orbital type of camera.
  42825. *
  42826. * 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.
  42827. * 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.
  42828. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42829. */
  42830. export class ArcRotateCamera extends TargetCamera {
  42831. /**
  42832. * Defines the rotation angle of the camera along the longitudinal axis.
  42833. */
  42834. alpha: number;
  42835. /**
  42836. * Defines the rotation angle of the camera along the latitudinal axis.
  42837. */
  42838. beta: number;
  42839. /**
  42840. * Defines the radius of the camera from it s target point.
  42841. */
  42842. radius: number;
  42843. protected _target: Vector3;
  42844. protected _targetHost: Nullable<AbstractMesh>;
  42845. /**
  42846. * Defines the target point of the camera.
  42847. * The camera looks towards it form the radius distance.
  42848. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42849. */
  42850. get target(): Vector3;
  42851. set target(value: Vector3);
  42852. /**
  42853. * Define the current local position of the camera in the scene
  42854. */
  42855. get position(): Vector3;
  42856. set position(newPosition: Vector3);
  42857. protected _upToYMatrix: Matrix;
  42858. protected _YToUpMatrix: Matrix;
  42859. /**
  42860. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42861. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42862. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42863. */
  42864. set upVector(vec: Vector3);
  42865. get upVector(): Vector3;
  42866. /**
  42867. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42868. */
  42869. setMatUp(): void;
  42870. /**
  42871. * Current inertia value on the longitudinal axis.
  42872. * The bigger this number the longer it will take for the camera to stop.
  42873. */
  42874. inertialAlphaOffset: number;
  42875. /**
  42876. * Current inertia value on the latitudinal axis.
  42877. * The bigger this number the longer it will take for the camera to stop.
  42878. */
  42879. inertialBetaOffset: number;
  42880. /**
  42881. * Current inertia value on the radius axis.
  42882. * The bigger this number the longer it will take for the camera to stop.
  42883. */
  42884. inertialRadiusOffset: number;
  42885. /**
  42886. * Minimum allowed angle on the longitudinal axis.
  42887. * This can help limiting how the Camera is able to move in the scene.
  42888. */
  42889. lowerAlphaLimit: Nullable<number>;
  42890. /**
  42891. * Maximum allowed angle on the longitudinal axis.
  42892. * This can help limiting how the Camera is able to move in the scene.
  42893. */
  42894. upperAlphaLimit: Nullable<number>;
  42895. /**
  42896. * Minimum allowed angle on the latitudinal axis.
  42897. * This can help limiting how the Camera is able to move in the scene.
  42898. */
  42899. lowerBetaLimit: number;
  42900. /**
  42901. * Maximum allowed angle on the latitudinal axis.
  42902. * This can help limiting how the Camera is able to move in the scene.
  42903. */
  42904. upperBetaLimit: number;
  42905. /**
  42906. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42907. * This can help limiting how the Camera is able to move in the scene.
  42908. */
  42909. lowerRadiusLimit: Nullable<number>;
  42910. /**
  42911. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42912. * This can help limiting how the Camera is able to move in the scene.
  42913. */
  42914. upperRadiusLimit: Nullable<number>;
  42915. /**
  42916. * Defines the current inertia value used during panning of the camera along the X axis.
  42917. */
  42918. inertialPanningX: number;
  42919. /**
  42920. * Defines the current inertia value used during panning of the camera along the Y axis.
  42921. */
  42922. inertialPanningY: number;
  42923. /**
  42924. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42925. * Basically if your fingers moves away from more than this distance you will be considered
  42926. * in pinch mode.
  42927. */
  42928. pinchToPanMaxDistance: number;
  42929. /**
  42930. * Defines the maximum distance the camera can pan.
  42931. * This could help keeping the cammera always in your scene.
  42932. */
  42933. panningDistanceLimit: Nullable<number>;
  42934. /**
  42935. * Defines the target of the camera before paning.
  42936. */
  42937. panningOriginTarget: Vector3;
  42938. /**
  42939. * Defines the value of the inertia used during panning.
  42940. * 0 would mean stop inertia and one would mean no decelleration at all.
  42941. */
  42942. panningInertia: number;
  42943. /**
  42944. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42945. */
  42946. get angularSensibilityX(): number;
  42947. set angularSensibilityX(value: number);
  42948. /**
  42949. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42950. */
  42951. get angularSensibilityY(): number;
  42952. set angularSensibilityY(value: number);
  42953. /**
  42954. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42955. */
  42956. get pinchPrecision(): number;
  42957. set pinchPrecision(value: number);
  42958. /**
  42959. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42960. * It will be used instead of pinchDeltaPrecision if different from 0.
  42961. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42962. */
  42963. get pinchDeltaPercentage(): number;
  42964. set pinchDeltaPercentage(value: number);
  42965. /**
  42966. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42967. * and pinch delta percentage.
  42968. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42969. * that any object in the plane at the camera's target point will scale
  42970. * perfectly with finger motion.
  42971. */
  42972. get useNaturalPinchZoom(): boolean;
  42973. set useNaturalPinchZoom(value: boolean);
  42974. /**
  42975. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42976. */
  42977. get panningSensibility(): number;
  42978. set panningSensibility(value: number);
  42979. /**
  42980. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42981. */
  42982. get keysUp(): number[];
  42983. set keysUp(value: number[]);
  42984. /**
  42985. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42986. */
  42987. get keysDown(): number[];
  42988. set keysDown(value: number[]);
  42989. /**
  42990. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42991. */
  42992. get keysLeft(): number[];
  42993. set keysLeft(value: number[]);
  42994. /**
  42995. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42996. */
  42997. get keysRight(): number[];
  42998. set keysRight(value: number[]);
  42999. /**
  43000. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43001. */
  43002. get wheelPrecision(): number;
  43003. set wheelPrecision(value: number);
  43004. /**
  43005. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43006. * It will be used instead of pinchDeltaPrecision if different from 0.
  43007. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43008. */
  43009. get wheelDeltaPercentage(): number;
  43010. set wheelDeltaPercentage(value: number);
  43011. /**
  43012. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43013. */
  43014. zoomOnFactor: number;
  43015. /**
  43016. * Defines a screen offset for the camera position.
  43017. */
  43018. targetScreenOffset: Vector2;
  43019. /**
  43020. * Allows the camera to be completely reversed.
  43021. * If false the camera can not arrive upside down.
  43022. */
  43023. allowUpsideDown: boolean;
  43024. /**
  43025. * Define if double tap/click is used to restore the previously saved state of the camera.
  43026. */
  43027. useInputToRestoreState: boolean;
  43028. /** @hidden */
  43029. _viewMatrix: Matrix;
  43030. /** @hidden */
  43031. _useCtrlForPanning: boolean;
  43032. /** @hidden */
  43033. _panningMouseButton: number;
  43034. /**
  43035. * Defines the input associated to the camera.
  43036. */
  43037. inputs: ArcRotateCameraInputsManager;
  43038. /** @hidden */
  43039. _reset: () => void;
  43040. /**
  43041. * Defines the allowed panning axis.
  43042. */
  43043. panningAxis: Vector3;
  43044. protected _localDirection: Vector3;
  43045. protected _transformedDirection: Vector3;
  43046. private _bouncingBehavior;
  43047. /**
  43048. * Gets the bouncing behavior of the camera if it has been enabled.
  43049. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43050. */
  43051. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43052. /**
  43053. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43054. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43055. */
  43056. get useBouncingBehavior(): boolean;
  43057. set useBouncingBehavior(value: boolean);
  43058. private _framingBehavior;
  43059. /**
  43060. * Gets the framing behavior of the camera if it has been enabled.
  43061. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43062. */
  43063. get framingBehavior(): Nullable<FramingBehavior>;
  43064. /**
  43065. * Defines if the framing behavior of the camera is enabled on the camera.
  43066. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43067. */
  43068. get useFramingBehavior(): boolean;
  43069. set useFramingBehavior(value: boolean);
  43070. private _autoRotationBehavior;
  43071. /**
  43072. * Gets the auto rotation behavior of the camera if it has been enabled.
  43073. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43074. */
  43075. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43076. /**
  43077. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43078. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43079. */
  43080. get useAutoRotationBehavior(): boolean;
  43081. set useAutoRotationBehavior(value: boolean);
  43082. /**
  43083. * Observable triggered when the mesh target has been changed on the camera.
  43084. */
  43085. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43086. /**
  43087. * Event raised when the camera is colliding with a mesh.
  43088. */
  43089. onCollide: (collidedMesh: AbstractMesh) => void;
  43090. /**
  43091. * Defines whether the camera should check collision with the objects oh the scene.
  43092. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43093. */
  43094. checkCollisions: boolean;
  43095. /**
  43096. * Defines the collision radius of the camera.
  43097. * This simulates a sphere around the camera.
  43098. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43099. */
  43100. collisionRadius: Vector3;
  43101. protected _collider: Collider;
  43102. protected _previousPosition: Vector3;
  43103. protected _collisionVelocity: Vector3;
  43104. protected _newPosition: Vector3;
  43105. protected _previousAlpha: number;
  43106. protected _previousBeta: number;
  43107. protected _previousRadius: number;
  43108. protected _collisionTriggered: boolean;
  43109. protected _targetBoundingCenter: Nullable<Vector3>;
  43110. private _computationVector;
  43111. /**
  43112. * Instantiates a new ArcRotateCamera in a given scene
  43113. * @param name Defines the name of the camera
  43114. * @param alpha Defines the camera rotation along the logitudinal axis
  43115. * @param beta Defines the camera rotation along the latitudinal axis
  43116. * @param radius Defines the camera distance from its target
  43117. * @param target Defines the camera target
  43118. * @param scene Defines the scene the camera belongs to
  43119. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43120. */
  43121. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43122. /** @hidden */
  43123. _initCache(): void;
  43124. /** @hidden */
  43125. _updateCache(ignoreParentClass?: boolean): void;
  43126. protected _getTargetPosition(): Vector3;
  43127. private _storedAlpha;
  43128. private _storedBeta;
  43129. private _storedRadius;
  43130. private _storedTarget;
  43131. private _storedTargetScreenOffset;
  43132. /**
  43133. * Stores the current state of the camera (alpha, beta, radius and target)
  43134. * @returns the camera itself
  43135. */
  43136. storeState(): Camera;
  43137. /**
  43138. * @hidden
  43139. * Restored camera state. You must call storeState() first
  43140. */
  43141. _restoreStateValues(): boolean;
  43142. /** @hidden */
  43143. _isSynchronizedViewMatrix(): boolean;
  43144. /**
  43145. * Attached controls to the current camera.
  43146. * @param element Defines the element the controls should be listened from
  43147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43148. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43149. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43150. */
  43151. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43152. /**
  43153. * Detach the current controls from the camera.
  43154. * The camera will stop reacting to inputs.
  43155. * @param element Defines the element to stop listening the inputs from
  43156. */
  43157. detachControl(element: HTMLElement): void;
  43158. /** @hidden */
  43159. _checkInputs(): void;
  43160. protected _checkLimits(): void;
  43161. /**
  43162. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43163. */
  43164. rebuildAnglesAndRadius(): void;
  43165. /**
  43166. * Use a position to define the current camera related information like alpha, beta and radius
  43167. * @param position Defines the position to set the camera at
  43168. */
  43169. setPosition(position: Vector3): void;
  43170. /**
  43171. * Defines the target the camera should look at.
  43172. * This will automatically adapt alpha beta and radius to fit within the new target.
  43173. * @param target Defines the new target as a Vector or a mesh
  43174. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43175. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43176. */
  43177. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43178. /** @hidden */
  43179. _getViewMatrix(): Matrix;
  43180. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43181. /**
  43182. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43183. * @param meshes Defines the mesh to zoom on
  43184. * @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)
  43185. */
  43186. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43187. /**
  43188. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43189. * The target will be changed but the radius
  43190. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43191. * @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)
  43192. */
  43193. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43194. min: Vector3;
  43195. max: Vector3;
  43196. distance: number;
  43197. }, doNotUpdateMaxZ?: boolean): void;
  43198. /**
  43199. * @override
  43200. * Override Camera.createRigCamera
  43201. */
  43202. createRigCamera(name: string, cameraIndex: number): Camera;
  43203. /**
  43204. * @hidden
  43205. * @override
  43206. * Override Camera._updateRigCameras
  43207. */
  43208. _updateRigCameras(): void;
  43209. /**
  43210. * Destroy the camera and release the current resources hold by it.
  43211. */
  43212. dispose(): void;
  43213. /**
  43214. * Gets the current object class name.
  43215. * @return the class name
  43216. */
  43217. getClassName(): string;
  43218. }
  43219. }
  43220. declare module BABYLON {
  43221. /**
  43222. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43223. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43224. */
  43225. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43226. /**
  43227. * Gets the name of the behavior.
  43228. */
  43229. get name(): string;
  43230. private _zoomStopsAnimation;
  43231. private _idleRotationSpeed;
  43232. private _idleRotationWaitTime;
  43233. private _idleRotationSpinupTime;
  43234. /**
  43235. * Sets the flag that indicates if user zooming should stop animation.
  43236. */
  43237. set zoomStopsAnimation(flag: boolean);
  43238. /**
  43239. * Gets the flag that indicates if user zooming should stop animation.
  43240. */
  43241. get zoomStopsAnimation(): boolean;
  43242. /**
  43243. * Sets the default speed at which the camera rotates around the model.
  43244. */
  43245. set idleRotationSpeed(speed: number);
  43246. /**
  43247. * Gets the default speed at which the camera rotates around the model.
  43248. */
  43249. get idleRotationSpeed(): number;
  43250. /**
  43251. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43252. */
  43253. set idleRotationWaitTime(time: number);
  43254. /**
  43255. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43256. */
  43257. get idleRotationWaitTime(): number;
  43258. /**
  43259. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43260. */
  43261. set idleRotationSpinupTime(time: number);
  43262. /**
  43263. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43264. */
  43265. get idleRotationSpinupTime(): number;
  43266. /**
  43267. * Gets a value indicating if the camera is currently rotating because of this behavior
  43268. */
  43269. get rotationInProgress(): boolean;
  43270. private _onPrePointerObservableObserver;
  43271. private _onAfterCheckInputsObserver;
  43272. private _attachedCamera;
  43273. private _isPointerDown;
  43274. private _lastFrameTime;
  43275. private _lastInteractionTime;
  43276. private _cameraRotationSpeed;
  43277. /**
  43278. * Initializes the behavior.
  43279. */
  43280. init(): void;
  43281. /**
  43282. * Attaches the behavior to its arc rotate camera.
  43283. * @param camera Defines the camera to attach the behavior to
  43284. */
  43285. attach(camera: ArcRotateCamera): void;
  43286. /**
  43287. * Detaches the behavior from its current arc rotate camera.
  43288. */
  43289. detach(): void;
  43290. /**
  43291. * Returns true if user is scrolling.
  43292. * @return true if user is scrolling.
  43293. */
  43294. private _userIsZooming;
  43295. private _lastFrameRadius;
  43296. private _shouldAnimationStopForInteraction;
  43297. /**
  43298. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43299. */
  43300. private _applyUserInteraction;
  43301. private _userIsMoving;
  43302. }
  43303. }
  43304. declare module BABYLON {
  43305. /**
  43306. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43307. */
  43308. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43309. private ui;
  43310. /**
  43311. * The name of the behavior
  43312. */
  43313. name: string;
  43314. /**
  43315. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43316. */
  43317. distanceAwayFromFace: number;
  43318. /**
  43319. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43320. */
  43321. distanceAwayFromBottomOfFace: number;
  43322. private _faceVectors;
  43323. private _target;
  43324. private _scene;
  43325. private _onRenderObserver;
  43326. private _tmpMatrix;
  43327. private _tmpVector;
  43328. /**
  43329. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43330. * @param ui The transform node that should be attched to the mesh
  43331. */
  43332. constructor(ui: TransformNode);
  43333. /**
  43334. * Initializes the behavior
  43335. */
  43336. init(): void;
  43337. private _closestFace;
  43338. private _zeroVector;
  43339. private _lookAtTmpMatrix;
  43340. private _lookAtToRef;
  43341. /**
  43342. * Attaches the AttachToBoxBehavior to the passed in mesh
  43343. * @param target The mesh that the specified node will be attached to
  43344. */
  43345. attach(target: Mesh): void;
  43346. /**
  43347. * Detaches the behavior from the mesh
  43348. */
  43349. detach(): void;
  43350. }
  43351. }
  43352. declare module BABYLON {
  43353. /**
  43354. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43355. */
  43356. export class FadeInOutBehavior implements Behavior<Mesh> {
  43357. /**
  43358. * Time in milliseconds to delay before fading in (Default: 0)
  43359. */
  43360. delay: number;
  43361. /**
  43362. * Time in milliseconds for the mesh to fade in (Default: 300)
  43363. */
  43364. fadeInTime: number;
  43365. private _millisecondsPerFrame;
  43366. private _hovered;
  43367. private _hoverValue;
  43368. private _ownerNode;
  43369. /**
  43370. * Instatiates the FadeInOutBehavior
  43371. */
  43372. constructor();
  43373. /**
  43374. * The name of the behavior
  43375. */
  43376. get name(): string;
  43377. /**
  43378. * Initializes the behavior
  43379. */
  43380. init(): void;
  43381. /**
  43382. * Attaches the fade behavior on the passed in mesh
  43383. * @param ownerNode The mesh that will be faded in/out once attached
  43384. */
  43385. attach(ownerNode: Mesh): void;
  43386. /**
  43387. * Detaches the behavior from the mesh
  43388. */
  43389. detach(): void;
  43390. /**
  43391. * Triggers the mesh to begin fading in or out
  43392. * @param value if the object should fade in or out (true to fade in)
  43393. */
  43394. fadeIn(value: boolean): void;
  43395. private _update;
  43396. private _setAllVisibility;
  43397. }
  43398. }
  43399. declare module BABYLON {
  43400. /**
  43401. * Class containing a set of static utilities functions for managing Pivots
  43402. * @hidden
  43403. */
  43404. export class PivotTools {
  43405. private static _PivotCached;
  43406. private static _OldPivotPoint;
  43407. private static _PivotTranslation;
  43408. private static _PivotTmpVector;
  43409. private static _PivotPostMultiplyPivotMatrix;
  43410. /** @hidden */
  43411. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43412. /** @hidden */
  43413. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43414. }
  43415. }
  43416. declare module BABYLON {
  43417. /**
  43418. * Class containing static functions to help procedurally build meshes
  43419. */
  43420. export class PlaneBuilder {
  43421. /**
  43422. * Creates a plane mesh
  43423. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43424. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43425. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43427. * * 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
  43428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43429. * @param name defines the name of the mesh
  43430. * @param options defines the options used to create the mesh
  43431. * @param scene defines the hosting scene
  43432. * @returns the plane mesh
  43433. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43434. */
  43435. static CreatePlane(name: string, options: {
  43436. size?: number;
  43437. width?: number;
  43438. height?: number;
  43439. sideOrientation?: number;
  43440. frontUVs?: Vector4;
  43441. backUVs?: Vector4;
  43442. updatable?: boolean;
  43443. sourcePlane?: Plane;
  43444. }, scene?: Nullable<Scene>): Mesh;
  43445. }
  43446. }
  43447. declare module BABYLON {
  43448. /**
  43449. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43450. */
  43451. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43452. private static _AnyMouseID;
  43453. /**
  43454. * Abstract mesh the behavior is set on
  43455. */
  43456. attachedNode: AbstractMesh;
  43457. private _dragPlane;
  43458. private _scene;
  43459. private _pointerObserver;
  43460. private _beforeRenderObserver;
  43461. private static _planeScene;
  43462. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43463. /**
  43464. * 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)
  43465. */
  43466. maxDragAngle: number;
  43467. /**
  43468. * @hidden
  43469. */
  43470. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43471. /**
  43472. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43473. */
  43474. currentDraggingPointerID: number;
  43475. /**
  43476. * The last position where the pointer hit the drag plane in world space
  43477. */
  43478. lastDragPosition: Vector3;
  43479. /**
  43480. * If the behavior is currently in a dragging state
  43481. */
  43482. dragging: boolean;
  43483. /**
  43484. * 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)
  43485. */
  43486. dragDeltaRatio: number;
  43487. /**
  43488. * If the drag plane orientation should be updated during the dragging (Default: true)
  43489. */
  43490. updateDragPlane: boolean;
  43491. private _debugMode;
  43492. private _moving;
  43493. /**
  43494. * Fires each time the attached mesh is dragged with the pointer
  43495. * * delta between last drag position and current drag position in world space
  43496. * * dragDistance along the drag axis
  43497. * * dragPlaneNormal normal of the current drag plane used during the drag
  43498. * * dragPlanePoint in world space where the drag intersects the drag plane
  43499. */
  43500. onDragObservable: Observable<{
  43501. delta: Vector3;
  43502. dragPlanePoint: Vector3;
  43503. dragPlaneNormal: Vector3;
  43504. dragDistance: number;
  43505. pointerId: number;
  43506. }>;
  43507. /**
  43508. * Fires each time a drag begins (eg. mouse down on mesh)
  43509. */
  43510. onDragStartObservable: Observable<{
  43511. dragPlanePoint: Vector3;
  43512. pointerId: number;
  43513. }>;
  43514. /**
  43515. * Fires each time a drag ends (eg. mouse release after drag)
  43516. */
  43517. onDragEndObservable: Observable<{
  43518. dragPlanePoint: Vector3;
  43519. pointerId: number;
  43520. }>;
  43521. /**
  43522. * If the attached mesh should be moved when dragged
  43523. */
  43524. moveAttached: boolean;
  43525. /**
  43526. * If the drag behavior will react to drag events (Default: true)
  43527. */
  43528. enabled: boolean;
  43529. /**
  43530. * If pointer events should start and release the drag (Default: true)
  43531. */
  43532. startAndReleaseDragOnPointerEvents: boolean;
  43533. /**
  43534. * If camera controls should be detached during the drag
  43535. */
  43536. detachCameraControls: boolean;
  43537. /**
  43538. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43539. */
  43540. useObjectOrientationForDragging: boolean;
  43541. private _options;
  43542. /**
  43543. * Gets the options used by the behavior
  43544. */
  43545. get options(): {
  43546. dragAxis?: Vector3;
  43547. dragPlaneNormal?: Vector3;
  43548. };
  43549. /**
  43550. * Sets the options used by the behavior
  43551. */
  43552. set options(options: {
  43553. dragAxis?: Vector3;
  43554. dragPlaneNormal?: Vector3;
  43555. });
  43556. /**
  43557. * Creates a pointer drag behavior that can be attached to a mesh
  43558. * @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)
  43559. */
  43560. constructor(options?: {
  43561. dragAxis?: Vector3;
  43562. dragPlaneNormal?: Vector3;
  43563. });
  43564. /**
  43565. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43566. */
  43567. validateDrag: (targetPosition: Vector3) => boolean;
  43568. /**
  43569. * The name of the behavior
  43570. */
  43571. get name(): string;
  43572. /**
  43573. * Initializes the behavior
  43574. */
  43575. init(): void;
  43576. private _tmpVector;
  43577. private _alternatePickedPoint;
  43578. private _worldDragAxis;
  43579. private _targetPosition;
  43580. private _attachedElement;
  43581. /**
  43582. * Attaches the drag behavior the passed in mesh
  43583. * @param ownerNode The mesh that will be dragged around once attached
  43584. * @param predicate Predicate to use for pick filtering
  43585. */
  43586. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43587. /**
  43588. * Force relase the drag action by code.
  43589. */
  43590. releaseDrag(): void;
  43591. private _startDragRay;
  43592. private _lastPointerRay;
  43593. /**
  43594. * Simulates the start of a pointer drag event on the behavior
  43595. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43596. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43597. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43598. */
  43599. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43600. private _startDrag;
  43601. private _dragDelta;
  43602. private _moveDrag;
  43603. private _pickWithRayOnDragPlane;
  43604. private _pointA;
  43605. private _pointC;
  43606. private _localAxis;
  43607. private _lookAt;
  43608. private _updateDragPlanePosition;
  43609. /**
  43610. * Detaches the behavior from the mesh
  43611. */
  43612. detach(): void;
  43613. }
  43614. }
  43615. declare module BABYLON {
  43616. /**
  43617. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43618. */
  43619. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43620. private _dragBehaviorA;
  43621. private _dragBehaviorB;
  43622. private _startDistance;
  43623. private _initialScale;
  43624. private _targetScale;
  43625. private _ownerNode;
  43626. private _sceneRenderObserver;
  43627. /**
  43628. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43629. */
  43630. constructor();
  43631. /**
  43632. * The name of the behavior
  43633. */
  43634. get name(): string;
  43635. /**
  43636. * Initializes the behavior
  43637. */
  43638. init(): void;
  43639. private _getCurrentDistance;
  43640. /**
  43641. * Attaches the scale behavior the passed in mesh
  43642. * @param ownerNode The mesh that will be scaled around once attached
  43643. */
  43644. attach(ownerNode: Mesh): void;
  43645. /**
  43646. * Detaches the behavior from the mesh
  43647. */
  43648. detach(): void;
  43649. }
  43650. }
  43651. declare module BABYLON {
  43652. /**
  43653. * 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
  43654. */
  43655. export class SixDofDragBehavior implements Behavior<Mesh> {
  43656. private static _virtualScene;
  43657. private _ownerNode;
  43658. private _sceneRenderObserver;
  43659. private _scene;
  43660. private _targetPosition;
  43661. private _virtualOriginMesh;
  43662. private _virtualDragMesh;
  43663. private _pointerObserver;
  43664. private _moving;
  43665. private _startingOrientation;
  43666. private _attachedElement;
  43667. /**
  43668. * 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)
  43669. */
  43670. private zDragFactor;
  43671. /**
  43672. * If the object should rotate to face the drag origin
  43673. */
  43674. rotateDraggedObject: boolean;
  43675. /**
  43676. * If the behavior is currently in a dragging state
  43677. */
  43678. dragging: boolean;
  43679. /**
  43680. * 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)
  43681. */
  43682. dragDeltaRatio: number;
  43683. /**
  43684. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43685. */
  43686. currentDraggingPointerID: number;
  43687. /**
  43688. * If camera controls should be detached during the drag
  43689. */
  43690. detachCameraControls: boolean;
  43691. /**
  43692. * Fires each time a drag starts
  43693. */
  43694. onDragStartObservable: Observable<{}>;
  43695. /**
  43696. * Fires each time a drag ends (eg. mouse release after drag)
  43697. */
  43698. onDragEndObservable: Observable<{}>;
  43699. /**
  43700. * 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
  43701. */
  43702. constructor();
  43703. /**
  43704. * The name of the behavior
  43705. */
  43706. get name(): string;
  43707. /**
  43708. * Initializes the behavior
  43709. */
  43710. init(): void;
  43711. /**
  43712. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43713. */
  43714. private get _pointerCamera();
  43715. /**
  43716. * Attaches the scale behavior the passed in mesh
  43717. * @param ownerNode The mesh that will be scaled around once attached
  43718. */
  43719. attach(ownerNode: Mesh): void;
  43720. /**
  43721. * Detaches the behavior from the mesh
  43722. */
  43723. detach(): void;
  43724. }
  43725. }
  43726. declare module BABYLON {
  43727. /**
  43728. * Class used to apply inverse kinematics to bones
  43729. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43730. */
  43731. export class BoneIKController {
  43732. private static _tmpVecs;
  43733. private static _tmpQuat;
  43734. private static _tmpMats;
  43735. /**
  43736. * Gets or sets the target mesh
  43737. */
  43738. targetMesh: AbstractMesh;
  43739. /** Gets or sets the mesh used as pole */
  43740. poleTargetMesh: AbstractMesh;
  43741. /**
  43742. * Gets or sets the bone used as pole
  43743. */
  43744. poleTargetBone: Nullable<Bone>;
  43745. /**
  43746. * Gets or sets the target position
  43747. */
  43748. targetPosition: Vector3;
  43749. /**
  43750. * Gets or sets the pole target position
  43751. */
  43752. poleTargetPosition: Vector3;
  43753. /**
  43754. * Gets or sets the pole target local offset
  43755. */
  43756. poleTargetLocalOffset: Vector3;
  43757. /**
  43758. * Gets or sets the pole angle
  43759. */
  43760. poleAngle: number;
  43761. /**
  43762. * Gets or sets the mesh associated with the controller
  43763. */
  43764. mesh: AbstractMesh;
  43765. /**
  43766. * 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)
  43767. */
  43768. slerpAmount: number;
  43769. private _bone1Quat;
  43770. private _bone1Mat;
  43771. private _bone2Ang;
  43772. private _bone1;
  43773. private _bone2;
  43774. private _bone1Length;
  43775. private _bone2Length;
  43776. private _maxAngle;
  43777. private _maxReach;
  43778. private _rightHandedSystem;
  43779. private _bendAxis;
  43780. private _slerping;
  43781. private _adjustRoll;
  43782. /**
  43783. * Gets or sets maximum allowed angle
  43784. */
  43785. get maxAngle(): number;
  43786. set maxAngle(value: number);
  43787. /**
  43788. * Creates a new BoneIKController
  43789. * @param mesh defines the mesh to control
  43790. * @param bone defines the bone to control
  43791. * @param options defines options to set up the controller
  43792. */
  43793. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43794. targetMesh?: AbstractMesh;
  43795. poleTargetMesh?: AbstractMesh;
  43796. poleTargetBone?: Bone;
  43797. poleTargetLocalOffset?: Vector3;
  43798. poleAngle?: number;
  43799. bendAxis?: Vector3;
  43800. maxAngle?: number;
  43801. slerpAmount?: number;
  43802. });
  43803. private _setMaxAngle;
  43804. /**
  43805. * Force the controller to update the bones
  43806. */
  43807. update(): void;
  43808. }
  43809. }
  43810. declare module BABYLON {
  43811. /**
  43812. * Class used to make a bone look toward a point in space
  43813. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43814. */
  43815. export class BoneLookController {
  43816. private static _tmpVecs;
  43817. private static _tmpQuat;
  43818. private static _tmpMats;
  43819. /**
  43820. * The target Vector3 that the bone will look at
  43821. */
  43822. target: Vector3;
  43823. /**
  43824. * The mesh that the bone is attached to
  43825. */
  43826. mesh: AbstractMesh;
  43827. /**
  43828. * The bone that will be looking to the target
  43829. */
  43830. bone: Bone;
  43831. /**
  43832. * The up axis of the coordinate system that is used when the bone is rotated
  43833. */
  43834. upAxis: Vector3;
  43835. /**
  43836. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43837. */
  43838. upAxisSpace: Space;
  43839. /**
  43840. * Used to make an adjustment to the yaw of the bone
  43841. */
  43842. adjustYaw: number;
  43843. /**
  43844. * Used to make an adjustment to the pitch of the bone
  43845. */
  43846. adjustPitch: number;
  43847. /**
  43848. * Used to make an adjustment to the roll of the bone
  43849. */
  43850. adjustRoll: number;
  43851. /**
  43852. * 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)
  43853. */
  43854. slerpAmount: number;
  43855. private _minYaw;
  43856. private _maxYaw;
  43857. private _minPitch;
  43858. private _maxPitch;
  43859. private _minYawSin;
  43860. private _minYawCos;
  43861. private _maxYawSin;
  43862. private _maxYawCos;
  43863. private _midYawConstraint;
  43864. private _minPitchTan;
  43865. private _maxPitchTan;
  43866. private _boneQuat;
  43867. private _slerping;
  43868. private _transformYawPitch;
  43869. private _transformYawPitchInv;
  43870. private _firstFrameSkipped;
  43871. private _yawRange;
  43872. private _fowardAxis;
  43873. /**
  43874. * Gets or sets the minimum yaw angle that the bone can look to
  43875. */
  43876. get minYaw(): number;
  43877. set minYaw(value: number);
  43878. /**
  43879. * Gets or sets the maximum yaw angle that the bone can look to
  43880. */
  43881. get maxYaw(): number;
  43882. set maxYaw(value: number);
  43883. /**
  43884. * Gets or sets the minimum pitch angle that the bone can look to
  43885. */
  43886. get minPitch(): number;
  43887. set minPitch(value: number);
  43888. /**
  43889. * Gets or sets the maximum pitch angle that the bone can look to
  43890. */
  43891. get maxPitch(): number;
  43892. set maxPitch(value: number);
  43893. /**
  43894. * Create a BoneLookController
  43895. * @param mesh the mesh that the bone belongs to
  43896. * @param bone the bone that will be looking to the target
  43897. * @param target the target Vector3 to look at
  43898. * @param options optional settings:
  43899. * * maxYaw: the maximum angle the bone will yaw to
  43900. * * minYaw: the minimum angle the bone will yaw to
  43901. * * maxPitch: the maximum angle the bone will pitch to
  43902. * * minPitch: the minimum angle the bone will yaw to
  43903. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43904. * * upAxis: the up axis of the coordinate system
  43905. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43906. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43907. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43908. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43909. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43910. * * adjustRoll: used to make an adjustment to the roll of the bone
  43911. **/
  43912. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43913. maxYaw?: number;
  43914. minYaw?: number;
  43915. maxPitch?: number;
  43916. minPitch?: number;
  43917. slerpAmount?: number;
  43918. upAxis?: Vector3;
  43919. upAxisSpace?: Space;
  43920. yawAxis?: Vector3;
  43921. pitchAxis?: Vector3;
  43922. adjustYaw?: number;
  43923. adjustPitch?: number;
  43924. adjustRoll?: number;
  43925. });
  43926. /**
  43927. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43928. */
  43929. update(): void;
  43930. private _getAngleDiff;
  43931. private _getAngleBetween;
  43932. private _isAngleBetween;
  43933. }
  43934. }
  43935. declare module BABYLON {
  43936. /**
  43937. * Manage the gamepad inputs to control an arc rotate camera.
  43938. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43939. */
  43940. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43941. /**
  43942. * Defines the camera the input is attached to.
  43943. */
  43944. camera: ArcRotateCamera;
  43945. /**
  43946. * Defines the gamepad the input is gathering event from.
  43947. */
  43948. gamepad: Nullable<Gamepad>;
  43949. /**
  43950. * Defines the gamepad rotation sensiblity.
  43951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43952. */
  43953. gamepadRotationSensibility: number;
  43954. /**
  43955. * Defines the gamepad move sensiblity.
  43956. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43957. */
  43958. gamepadMoveSensibility: number;
  43959. private _yAxisScale;
  43960. /**
  43961. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43962. */
  43963. get invertYAxis(): boolean;
  43964. set invertYAxis(value: boolean);
  43965. private _onGamepadConnectedObserver;
  43966. private _onGamepadDisconnectedObserver;
  43967. /**
  43968. * Attach the input controls to a specific dom element to get the input from.
  43969. * @param element Defines the element the controls should be listened from
  43970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43971. */
  43972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43973. /**
  43974. * Detach the current controls from the specified dom element.
  43975. * @param element Defines the element to stop listening the inputs from
  43976. */
  43977. detachControl(element: Nullable<HTMLElement>): void;
  43978. /**
  43979. * Update the current camera state depending on the inputs that have been used this frame.
  43980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43981. */
  43982. checkInputs(): void;
  43983. /**
  43984. * Gets the class name of the current intput.
  43985. * @returns the class name
  43986. */
  43987. getClassName(): string;
  43988. /**
  43989. * Get the friendly name associated with the input class.
  43990. * @returns the input friendly name
  43991. */
  43992. getSimpleName(): string;
  43993. }
  43994. }
  43995. declare module BABYLON {
  43996. interface ArcRotateCameraInputsManager {
  43997. /**
  43998. * Add orientation input support to the input manager.
  43999. * @returns the current input manager
  44000. */
  44001. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44002. }
  44003. /**
  44004. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44006. */
  44007. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44008. /**
  44009. * Defines the camera the input is attached to.
  44010. */
  44011. camera: ArcRotateCamera;
  44012. /**
  44013. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44014. */
  44015. alphaCorrection: number;
  44016. /**
  44017. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44018. */
  44019. gammaCorrection: number;
  44020. private _alpha;
  44021. private _gamma;
  44022. private _dirty;
  44023. private _deviceOrientationHandler;
  44024. /**
  44025. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44026. */
  44027. constructor();
  44028. /**
  44029. * Attach the input controls to a specific dom element to get the input from.
  44030. * @param element Defines the element the controls should be listened from
  44031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44032. */
  44033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44034. /** @hidden */
  44035. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44036. /**
  44037. * Update the current camera state depending on the inputs that have been used this frame.
  44038. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44039. */
  44040. checkInputs(): void;
  44041. /**
  44042. * Detach the current controls from the specified dom element.
  44043. * @param element Defines the element to stop listening the inputs from
  44044. */
  44045. detachControl(element: Nullable<HTMLElement>): void;
  44046. /**
  44047. * Gets the class name of the current intput.
  44048. * @returns the class name
  44049. */
  44050. getClassName(): string;
  44051. /**
  44052. * Get the friendly name associated with the input class.
  44053. * @returns the input friendly name
  44054. */
  44055. getSimpleName(): string;
  44056. }
  44057. }
  44058. declare module BABYLON {
  44059. /**
  44060. * Listen to mouse events to control the camera.
  44061. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44062. */
  44063. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44064. /**
  44065. * Defines the camera the input is attached to.
  44066. */
  44067. camera: FlyCamera;
  44068. /**
  44069. * Defines if touch is enabled. (Default is true.)
  44070. */
  44071. touchEnabled: boolean;
  44072. /**
  44073. * Defines the buttons associated with the input to handle camera rotation.
  44074. */
  44075. buttons: number[];
  44076. /**
  44077. * Assign buttons for Yaw control.
  44078. */
  44079. buttonsYaw: number[];
  44080. /**
  44081. * Assign buttons for Pitch control.
  44082. */
  44083. buttonsPitch: number[];
  44084. /**
  44085. * Assign buttons for Roll control.
  44086. */
  44087. buttonsRoll: number[];
  44088. /**
  44089. * Detect if any button is being pressed while mouse is moved.
  44090. * -1 = Mouse locked.
  44091. * 0 = Left button.
  44092. * 1 = Middle Button.
  44093. * 2 = Right Button.
  44094. */
  44095. activeButton: number;
  44096. /**
  44097. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44098. * Higher values reduce its sensitivity.
  44099. */
  44100. angularSensibility: number;
  44101. private _mousemoveCallback;
  44102. private _observer;
  44103. private _rollObserver;
  44104. private previousPosition;
  44105. private noPreventDefault;
  44106. private element;
  44107. /**
  44108. * Listen to mouse events to control the camera.
  44109. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44110. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44111. */
  44112. constructor(touchEnabled?: boolean);
  44113. /**
  44114. * Attach the mouse control to the HTML DOM element.
  44115. * @param element Defines the element that listens to the input events.
  44116. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44117. */
  44118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44119. /**
  44120. * Detach the current controls from the specified dom element.
  44121. * @param element Defines the element to stop listening the inputs from
  44122. */
  44123. detachControl(element: Nullable<HTMLElement>): void;
  44124. /**
  44125. * Gets the class name of the current input.
  44126. * @returns the class name.
  44127. */
  44128. getClassName(): string;
  44129. /**
  44130. * Get the friendly name associated with the input class.
  44131. * @returns the input's friendly name.
  44132. */
  44133. getSimpleName(): string;
  44134. private _pointerInput;
  44135. private _onMouseMove;
  44136. /**
  44137. * Rotate camera by mouse offset.
  44138. */
  44139. private rotateCamera;
  44140. }
  44141. }
  44142. declare module BABYLON {
  44143. /**
  44144. * Default Inputs manager for the FlyCamera.
  44145. * It groups all the default supported inputs for ease of use.
  44146. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44147. */
  44148. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44149. /**
  44150. * Instantiates a new FlyCameraInputsManager.
  44151. * @param camera Defines the camera the inputs belong to.
  44152. */
  44153. constructor(camera: FlyCamera);
  44154. /**
  44155. * Add keyboard input support to the input manager.
  44156. * @returns the new FlyCameraKeyboardMoveInput().
  44157. */
  44158. addKeyboard(): FlyCameraInputsManager;
  44159. /**
  44160. * Add mouse input support to the input manager.
  44161. * @param touchEnabled Enable touch screen support.
  44162. * @returns the new FlyCameraMouseInput().
  44163. */
  44164. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44165. }
  44166. }
  44167. declare module BABYLON {
  44168. /**
  44169. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44170. * such as in a 3D Space Shooter or a Flight Simulator.
  44171. */
  44172. export class FlyCamera extends TargetCamera {
  44173. /**
  44174. * Define the collision ellipsoid of the camera.
  44175. * This is helpful for simulating a camera body, like a player's body.
  44176. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44177. */
  44178. ellipsoid: Vector3;
  44179. /**
  44180. * Define an offset for the position of the ellipsoid around the camera.
  44181. * This can be helpful if the camera is attached away from the player's body center,
  44182. * such as at its head.
  44183. */
  44184. ellipsoidOffset: Vector3;
  44185. /**
  44186. * Enable or disable collisions of the camera with the rest of the scene objects.
  44187. */
  44188. checkCollisions: boolean;
  44189. /**
  44190. * Enable or disable gravity on the camera.
  44191. */
  44192. applyGravity: boolean;
  44193. /**
  44194. * Define the current direction the camera is moving to.
  44195. */
  44196. cameraDirection: Vector3;
  44197. /**
  44198. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44199. * This overrides and empties cameraRotation.
  44200. */
  44201. rotationQuaternion: Quaternion;
  44202. /**
  44203. * Track Roll to maintain the wanted Rolling when looking around.
  44204. */
  44205. _trackRoll: number;
  44206. /**
  44207. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44208. */
  44209. rollCorrect: number;
  44210. /**
  44211. * Mimic a banked turn, Rolling the camera when Yawing.
  44212. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44213. */
  44214. bankedTurn: boolean;
  44215. /**
  44216. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44217. */
  44218. bankedTurnLimit: number;
  44219. /**
  44220. * Value of 0 disables the banked Roll.
  44221. * Value of 1 is equal to the Yaw angle in radians.
  44222. */
  44223. bankedTurnMultiplier: number;
  44224. /**
  44225. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44226. */
  44227. inputs: FlyCameraInputsManager;
  44228. /**
  44229. * Gets the input sensibility for mouse input.
  44230. * Higher values reduce sensitivity.
  44231. */
  44232. get angularSensibility(): number;
  44233. /**
  44234. * Sets the input sensibility for a mouse input.
  44235. * Higher values reduce sensitivity.
  44236. */
  44237. set angularSensibility(value: number);
  44238. /**
  44239. * Get the keys for camera movement forward.
  44240. */
  44241. get keysForward(): number[];
  44242. /**
  44243. * Set the keys for camera movement forward.
  44244. */
  44245. set keysForward(value: number[]);
  44246. /**
  44247. * Get the keys for camera movement backward.
  44248. */
  44249. get keysBackward(): number[];
  44250. set keysBackward(value: number[]);
  44251. /**
  44252. * Get the keys for camera movement up.
  44253. */
  44254. get keysUp(): number[];
  44255. /**
  44256. * Set the keys for camera movement up.
  44257. */
  44258. set keysUp(value: number[]);
  44259. /**
  44260. * Get the keys for camera movement down.
  44261. */
  44262. get keysDown(): number[];
  44263. /**
  44264. * Set the keys for camera movement down.
  44265. */
  44266. set keysDown(value: number[]);
  44267. /**
  44268. * Get the keys for camera movement left.
  44269. */
  44270. get keysLeft(): number[];
  44271. /**
  44272. * Set the keys for camera movement left.
  44273. */
  44274. set keysLeft(value: number[]);
  44275. /**
  44276. * Set the keys for camera movement right.
  44277. */
  44278. get keysRight(): number[];
  44279. /**
  44280. * Set the keys for camera movement right.
  44281. */
  44282. set keysRight(value: number[]);
  44283. /**
  44284. * Event raised when the camera collides with a mesh in the scene.
  44285. */
  44286. onCollide: (collidedMesh: AbstractMesh) => void;
  44287. private _collider;
  44288. private _needMoveForGravity;
  44289. private _oldPosition;
  44290. private _diffPosition;
  44291. private _newPosition;
  44292. /** @hidden */
  44293. _localDirection: Vector3;
  44294. /** @hidden */
  44295. _transformedDirection: Vector3;
  44296. /**
  44297. * Instantiates a FlyCamera.
  44298. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44299. * such as in a 3D Space Shooter or a Flight Simulator.
  44300. * @param name Define the name of the camera in the scene.
  44301. * @param position Define the starting position of the camera in the scene.
  44302. * @param scene Define the scene the camera belongs to.
  44303. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44304. */
  44305. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44306. /**
  44307. * Attach a control to the HTML DOM element.
  44308. * @param element Defines the element that listens to the input events.
  44309. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44310. */
  44311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44312. /**
  44313. * Detach a control from the HTML DOM element.
  44314. * The camera will stop reacting to that input.
  44315. * @param element Defines the element that listens to the input events.
  44316. */
  44317. detachControl(element: HTMLElement): void;
  44318. private _collisionMask;
  44319. /**
  44320. * Get the mask that the camera ignores in collision events.
  44321. */
  44322. get collisionMask(): number;
  44323. /**
  44324. * Set the mask that the camera ignores in collision events.
  44325. */
  44326. set collisionMask(mask: number);
  44327. /** @hidden */
  44328. _collideWithWorld(displacement: Vector3): void;
  44329. /** @hidden */
  44330. private _onCollisionPositionChange;
  44331. /** @hidden */
  44332. _checkInputs(): void;
  44333. /** @hidden */
  44334. _decideIfNeedsToMove(): boolean;
  44335. /** @hidden */
  44336. _updatePosition(): void;
  44337. /**
  44338. * Restore the Roll to its target value at the rate specified.
  44339. * @param rate - Higher means slower restoring.
  44340. * @hidden
  44341. */
  44342. restoreRoll(rate: number): void;
  44343. /**
  44344. * Destroy the camera and release the current resources held by it.
  44345. */
  44346. dispose(): void;
  44347. /**
  44348. * Get the current object class name.
  44349. * @returns the class name.
  44350. */
  44351. getClassName(): string;
  44352. }
  44353. }
  44354. declare module BABYLON {
  44355. /**
  44356. * Listen to keyboard events to control the camera.
  44357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44358. */
  44359. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44360. /**
  44361. * Defines the camera the input is attached to.
  44362. */
  44363. camera: FlyCamera;
  44364. /**
  44365. * The list of keyboard keys used to control the forward move of the camera.
  44366. */
  44367. keysForward: number[];
  44368. /**
  44369. * The list of keyboard keys used to control the backward move of the camera.
  44370. */
  44371. keysBackward: number[];
  44372. /**
  44373. * The list of keyboard keys used to control the forward move of the camera.
  44374. */
  44375. keysUp: number[];
  44376. /**
  44377. * The list of keyboard keys used to control the backward move of the camera.
  44378. */
  44379. keysDown: number[];
  44380. /**
  44381. * The list of keyboard keys used to control the right strafe move of the camera.
  44382. */
  44383. keysRight: number[];
  44384. /**
  44385. * The list of keyboard keys used to control the left strafe move of the camera.
  44386. */
  44387. keysLeft: number[];
  44388. private _keys;
  44389. private _onCanvasBlurObserver;
  44390. private _onKeyboardObserver;
  44391. private _engine;
  44392. private _scene;
  44393. /**
  44394. * Attach the input controls to a specific dom element to get the input from.
  44395. * @param element Defines the element the controls should be listened from
  44396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44397. */
  44398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44399. /**
  44400. * Detach the current controls from the specified dom element.
  44401. * @param element Defines the element to stop listening the inputs from
  44402. */
  44403. detachControl(element: Nullable<HTMLElement>): void;
  44404. /**
  44405. * Gets the class name of the current intput.
  44406. * @returns the class name
  44407. */
  44408. getClassName(): string;
  44409. /** @hidden */
  44410. _onLostFocus(e: FocusEvent): void;
  44411. /**
  44412. * Get the friendly name associated with the input class.
  44413. * @returns the input friendly name
  44414. */
  44415. getSimpleName(): string;
  44416. /**
  44417. * Update the current camera state depending on the inputs that have been used this frame.
  44418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44419. */
  44420. checkInputs(): void;
  44421. }
  44422. }
  44423. declare module BABYLON {
  44424. /**
  44425. * Manage the mouse wheel inputs to control a follow camera.
  44426. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44427. */
  44428. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44429. /**
  44430. * Defines the camera the input is attached to.
  44431. */
  44432. camera: FollowCamera;
  44433. /**
  44434. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44435. */
  44436. axisControlRadius: boolean;
  44437. /**
  44438. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44439. */
  44440. axisControlHeight: boolean;
  44441. /**
  44442. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44443. */
  44444. axisControlRotation: boolean;
  44445. /**
  44446. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44447. * relation to mouseWheel events.
  44448. */
  44449. wheelPrecision: number;
  44450. /**
  44451. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44452. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44453. */
  44454. wheelDeltaPercentage: number;
  44455. private _wheel;
  44456. private _observer;
  44457. /**
  44458. * Attach the input controls to a specific dom element to get the input from.
  44459. * @param element Defines the element the controls should be listened from
  44460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44461. */
  44462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44463. /**
  44464. * Detach the current controls from the specified dom element.
  44465. * @param element Defines the element to stop listening the inputs from
  44466. */
  44467. detachControl(element: Nullable<HTMLElement>): void;
  44468. /**
  44469. * Gets the class name of the current intput.
  44470. * @returns the class name
  44471. */
  44472. getClassName(): string;
  44473. /**
  44474. * Get the friendly name associated with the input class.
  44475. * @returns the input friendly name
  44476. */
  44477. getSimpleName(): string;
  44478. }
  44479. }
  44480. declare module BABYLON {
  44481. /**
  44482. * Manage the pointers inputs to control an follow camera.
  44483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44484. */
  44485. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44486. /**
  44487. * Defines the camera the input is attached to.
  44488. */
  44489. camera: FollowCamera;
  44490. /**
  44491. * Gets the class name of the current input.
  44492. * @returns the class name
  44493. */
  44494. getClassName(): string;
  44495. /**
  44496. * Defines the pointer angular sensibility along the X axis or how fast is
  44497. * the camera rotating.
  44498. * A negative number will reverse the axis direction.
  44499. */
  44500. angularSensibilityX: number;
  44501. /**
  44502. * Defines the pointer angular sensibility along the Y axis or how fast is
  44503. * the camera rotating.
  44504. * A negative number will reverse the axis direction.
  44505. */
  44506. angularSensibilityY: number;
  44507. /**
  44508. * Defines the pointer pinch precision or how fast is the camera zooming.
  44509. * A negative number will reverse the axis direction.
  44510. */
  44511. pinchPrecision: number;
  44512. /**
  44513. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44514. * from 0.
  44515. * It defines the percentage of current camera.radius to use as delta when
  44516. * pinch zoom is used.
  44517. */
  44518. pinchDeltaPercentage: number;
  44519. /**
  44520. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44521. */
  44522. axisXControlRadius: boolean;
  44523. /**
  44524. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44525. */
  44526. axisXControlHeight: boolean;
  44527. /**
  44528. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44529. */
  44530. axisXControlRotation: boolean;
  44531. /**
  44532. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44533. */
  44534. axisYControlRadius: boolean;
  44535. /**
  44536. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44537. */
  44538. axisYControlHeight: boolean;
  44539. /**
  44540. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44541. */
  44542. axisYControlRotation: boolean;
  44543. /**
  44544. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44545. */
  44546. axisPinchControlRadius: boolean;
  44547. /**
  44548. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44549. */
  44550. axisPinchControlHeight: boolean;
  44551. /**
  44552. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44553. */
  44554. axisPinchControlRotation: boolean;
  44555. /**
  44556. * Log error messages if basic misconfiguration has occurred.
  44557. */
  44558. warningEnable: boolean;
  44559. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44560. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44561. private _warningCounter;
  44562. private _warning;
  44563. }
  44564. }
  44565. declare module BABYLON {
  44566. /**
  44567. * Default Inputs manager for the FollowCamera.
  44568. * It groups all the default supported inputs for ease of use.
  44569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44570. */
  44571. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44572. /**
  44573. * Instantiates a new FollowCameraInputsManager.
  44574. * @param camera Defines the camera the inputs belong to
  44575. */
  44576. constructor(camera: FollowCamera);
  44577. /**
  44578. * Add keyboard input support to the input manager.
  44579. * @returns the current input manager
  44580. */
  44581. addKeyboard(): FollowCameraInputsManager;
  44582. /**
  44583. * Add mouse wheel input support to the input manager.
  44584. * @returns the current input manager
  44585. */
  44586. addMouseWheel(): FollowCameraInputsManager;
  44587. /**
  44588. * Add pointers input support to the input manager.
  44589. * @returns the current input manager
  44590. */
  44591. addPointers(): FollowCameraInputsManager;
  44592. /**
  44593. * Add orientation input support to the input manager.
  44594. * @returns the current input manager
  44595. */
  44596. addVRDeviceOrientation(): FollowCameraInputsManager;
  44597. }
  44598. }
  44599. declare module BABYLON {
  44600. /**
  44601. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44602. * an arc rotate version arcFollowCamera are available.
  44603. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44604. */
  44605. export class FollowCamera extends TargetCamera {
  44606. /**
  44607. * Distance the follow camera should follow an object at
  44608. */
  44609. radius: number;
  44610. /**
  44611. * Minimum allowed distance of the camera to the axis of rotation
  44612. * (The camera can not get closer).
  44613. * This can help limiting how the Camera is able to move in the scene.
  44614. */
  44615. lowerRadiusLimit: Nullable<number>;
  44616. /**
  44617. * Maximum allowed distance of the camera to the axis of rotation
  44618. * (The camera can not get further).
  44619. * This can help limiting how the Camera is able to move in the scene.
  44620. */
  44621. upperRadiusLimit: Nullable<number>;
  44622. /**
  44623. * Define a rotation offset between the camera and the object it follows
  44624. */
  44625. rotationOffset: number;
  44626. /**
  44627. * Minimum allowed angle to camera position relative to target object.
  44628. * This can help limiting how the Camera is able to move in the scene.
  44629. */
  44630. lowerRotationOffsetLimit: Nullable<number>;
  44631. /**
  44632. * Maximum allowed angle to camera position relative to target object.
  44633. * This can help limiting how the Camera is able to move in the scene.
  44634. */
  44635. upperRotationOffsetLimit: Nullable<number>;
  44636. /**
  44637. * Define a height offset between the camera and the object it follows.
  44638. * It can help following an object from the top (like a car chaing a plane)
  44639. */
  44640. heightOffset: number;
  44641. /**
  44642. * Minimum allowed height of camera position relative to target object.
  44643. * This can help limiting how the Camera is able to move in the scene.
  44644. */
  44645. lowerHeightOffsetLimit: Nullable<number>;
  44646. /**
  44647. * Maximum allowed height of camera position relative to target object.
  44648. * This can help limiting how the Camera is able to move in the scene.
  44649. */
  44650. upperHeightOffsetLimit: Nullable<number>;
  44651. /**
  44652. * Define how fast the camera can accelerate to follow it s target.
  44653. */
  44654. cameraAcceleration: number;
  44655. /**
  44656. * Define the speed limit of the camera following an object.
  44657. */
  44658. maxCameraSpeed: number;
  44659. /**
  44660. * Define the target of the camera.
  44661. */
  44662. lockedTarget: Nullable<AbstractMesh>;
  44663. /**
  44664. * Defines the input associated with the camera.
  44665. */
  44666. inputs: FollowCameraInputsManager;
  44667. /**
  44668. * Instantiates the follow camera.
  44669. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44670. * @param name Define the name of the camera in the scene
  44671. * @param position Define the position of the camera
  44672. * @param scene Define the scene the camera belong to
  44673. * @param lockedTarget Define the target of the camera
  44674. */
  44675. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44676. private _follow;
  44677. /**
  44678. * Attached controls to the current camera.
  44679. * @param element Defines the element the controls should be listened from
  44680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44681. */
  44682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44683. /**
  44684. * Detach the current controls from the camera.
  44685. * The camera will stop reacting to inputs.
  44686. * @param element Defines the element to stop listening the inputs from
  44687. */
  44688. detachControl(element: HTMLElement): void;
  44689. /** @hidden */
  44690. _checkInputs(): void;
  44691. private _checkLimits;
  44692. /**
  44693. * Gets the camera class name.
  44694. * @returns the class name
  44695. */
  44696. getClassName(): string;
  44697. }
  44698. /**
  44699. * Arc Rotate version of the follow camera.
  44700. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44701. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44702. */
  44703. export class ArcFollowCamera extends TargetCamera {
  44704. /** The longitudinal angle of the camera */
  44705. alpha: number;
  44706. /** The latitudinal angle of the camera */
  44707. beta: number;
  44708. /** The radius of the camera from its target */
  44709. radius: number;
  44710. private _cartesianCoordinates;
  44711. /** Define the camera target (the mesh it should follow) */
  44712. private _meshTarget;
  44713. /**
  44714. * Instantiates a new ArcFollowCamera
  44715. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44716. * @param name Define the name of the camera
  44717. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44718. * @param beta Define the rotation angle of the camera around the elevation axis
  44719. * @param radius Define the radius of the camera from its target point
  44720. * @param target Define the target of the camera
  44721. * @param scene Define the scene the camera belongs to
  44722. */
  44723. constructor(name: string,
  44724. /** The longitudinal angle of the camera */
  44725. alpha: number,
  44726. /** The latitudinal angle of the camera */
  44727. beta: number,
  44728. /** The radius of the camera from its target */
  44729. radius: number,
  44730. /** Define the camera target (the mesh it should follow) */
  44731. target: Nullable<AbstractMesh>, scene: Scene);
  44732. private _follow;
  44733. /** @hidden */
  44734. _checkInputs(): void;
  44735. /**
  44736. * Returns the class name of the object.
  44737. * It is mostly used internally for serialization purposes.
  44738. */
  44739. getClassName(): string;
  44740. }
  44741. }
  44742. declare module BABYLON {
  44743. /**
  44744. * Manage the keyboard inputs to control the movement of a follow camera.
  44745. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44746. */
  44747. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44748. /**
  44749. * Defines the camera the input is attached to.
  44750. */
  44751. camera: FollowCamera;
  44752. /**
  44753. * Defines the list of key codes associated with the up action (increase heightOffset)
  44754. */
  44755. keysHeightOffsetIncr: number[];
  44756. /**
  44757. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44758. */
  44759. keysHeightOffsetDecr: number[];
  44760. /**
  44761. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44762. */
  44763. keysHeightOffsetModifierAlt: boolean;
  44764. /**
  44765. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44766. */
  44767. keysHeightOffsetModifierCtrl: boolean;
  44768. /**
  44769. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44770. */
  44771. keysHeightOffsetModifierShift: boolean;
  44772. /**
  44773. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44774. */
  44775. keysRotationOffsetIncr: number[];
  44776. /**
  44777. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44778. */
  44779. keysRotationOffsetDecr: number[];
  44780. /**
  44781. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44782. */
  44783. keysRotationOffsetModifierAlt: boolean;
  44784. /**
  44785. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44786. */
  44787. keysRotationOffsetModifierCtrl: boolean;
  44788. /**
  44789. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44790. */
  44791. keysRotationOffsetModifierShift: boolean;
  44792. /**
  44793. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44794. */
  44795. keysRadiusIncr: number[];
  44796. /**
  44797. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44798. */
  44799. keysRadiusDecr: number[];
  44800. /**
  44801. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44802. */
  44803. keysRadiusModifierAlt: boolean;
  44804. /**
  44805. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44806. */
  44807. keysRadiusModifierCtrl: boolean;
  44808. /**
  44809. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44810. */
  44811. keysRadiusModifierShift: boolean;
  44812. /**
  44813. * Defines the rate of change of heightOffset.
  44814. */
  44815. heightSensibility: number;
  44816. /**
  44817. * Defines the rate of change of rotationOffset.
  44818. */
  44819. rotationSensibility: number;
  44820. /**
  44821. * Defines the rate of change of radius.
  44822. */
  44823. radiusSensibility: number;
  44824. private _keys;
  44825. private _ctrlPressed;
  44826. private _altPressed;
  44827. private _shiftPressed;
  44828. private _onCanvasBlurObserver;
  44829. private _onKeyboardObserver;
  44830. private _engine;
  44831. private _scene;
  44832. /**
  44833. * Attach the input controls to a specific dom element to get the input from.
  44834. * @param element Defines the element the controls should be listened from
  44835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44836. */
  44837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44838. /**
  44839. * Detach the current controls from the specified dom element.
  44840. * @param element Defines the element to stop listening the inputs from
  44841. */
  44842. detachControl(element: Nullable<HTMLElement>): void;
  44843. /**
  44844. * Update the current camera state depending on the inputs that have been used this frame.
  44845. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44846. */
  44847. checkInputs(): void;
  44848. /**
  44849. * Gets the class name of the current input.
  44850. * @returns the class name
  44851. */
  44852. getClassName(): string;
  44853. /**
  44854. * Get the friendly name associated with the input class.
  44855. * @returns the input friendly name
  44856. */
  44857. getSimpleName(): string;
  44858. /**
  44859. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44860. * allow modification of the heightOffset value.
  44861. */
  44862. private _modifierHeightOffset;
  44863. /**
  44864. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44865. * allow modification of the rotationOffset value.
  44866. */
  44867. private _modifierRotationOffset;
  44868. /**
  44869. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44870. * allow modification of the radius value.
  44871. */
  44872. private _modifierRadius;
  44873. }
  44874. }
  44875. declare module BABYLON {
  44876. interface FreeCameraInputsManager {
  44877. /**
  44878. * @hidden
  44879. */
  44880. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44881. /**
  44882. * Add orientation input support to the input manager.
  44883. * @returns the current input manager
  44884. */
  44885. addDeviceOrientation(): FreeCameraInputsManager;
  44886. }
  44887. /**
  44888. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44889. * Screen rotation is taken into account.
  44890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44891. */
  44892. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44893. private _camera;
  44894. private _screenOrientationAngle;
  44895. private _constantTranform;
  44896. private _screenQuaternion;
  44897. private _alpha;
  44898. private _beta;
  44899. private _gamma;
  44900. /**
  44901. * Can be used to detect if a device orientation sensor is available on a device
  44902. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44903. * @returns a promise that will resolve on orientation change
  44904. */
  44905. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44906. /**
  44907. * @hidden
  44908. */
  44909. _onDeviceOrientationChangedObservable: Observable<void>;
  44910. /**
  44911. * Instantiates a new input
  44912. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44913. */
  44914. constructor();
  44915. /**
  44916. * Define the camera controlled by the input.
  44917. */
  44918. get camera(): FreeCamera;
  44919. set camera(camera: FreeCamera);
  44920. /**
  44921. * Attach the input controls to a specific dom element to get the input from.
  44922. * @param element Defines the element the controls should be listened from
  44923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44924. */
  44925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44926. private _orientationChanged;
  44927. private _deviceOrientation;
  44928. /**
  44929. * Detach the current controls from the specified dom element.
  44930. * @param element Defines the element to stop listening the inputs from
  44931. */
  44932. detachControl(element: Nullable<HTMLElement>): void;
  44933. /**
  44934. * Update the current camera state depending on the inputs that have been used this frame.
  44935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44936. */
  44937. checkInputs(): void;
  44938. /**
  44939. * Gets the class name of the current intput.
  44940. * @returns the class name
  44941. */
  44942. getClassName(): string;
  44943. /**
  44944. * Get the friendly name associated with the input class.
  44945. * @returns the input friendly name
  44946. */
  44947. getSimpleName(): string;
  44948. }
  44949. }
  44950. declare module BABYLON {
  44951. /**
  44952. * Manage the gamepad inputs to control a free camera.
  44953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44954. */
  44955. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44956. /**
  44957. * Define the camera the input is attached to.
  44958. */
  44959. camera: FreeCamera;
  44960. /**
  44961. * Define the Gamepad controlling the input
  44962. */
  44963. gamepad: Nullable<Gamepad>;
  44964. /**
  44965. * Defines the gamepad rotation sensiblity.
  44966. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44967. */
  44968. gamepadAngularSensibility: number;
  44969. /**
  44970. * Defines the gamepad move sensiblity.
  44971. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44972. */
  44973. gamepadMoveSensibility: number;
  44974. private _yAxisScale;
  44975. /**
  44976. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44977. */
  44978. get invertYAxis(): boolean;
  44979. set invertYAxis(value: boolean);
  44980. private _onGamepadConnectedObserver;
  44981. private _onGamepadDisconnectedObserver;
  44982. private _cameraTransform;
  44983. private _deltaTransform;
  44984. private _vector3;
  44985. private _vector2;
  44986. /**
  44987. * Attach the input controls to a specific dom element to get the input from.
  44988. * @param element Defines the element the controls should be listened from
  44989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44990. */
  44991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44992. /**
  44993. * Detach the current controls from the specified dom element.
  44994. * @param element Defines the element to stop listening the inputs from
  44995. */
  44996. detachControl(element: Nullable<HTMLElement>): void;
  44997. /**
  44998. * Update the current camera state depending on the inputs that have been used this frame.
  44999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45000. */
  45001. checkInputs(): void;
  45002. /**
  45003. * Gets the class name of the current intput.
  45004. * @returns the class name
  45005. */
  45006. getClassName(): string;
  45007. /**
  45008. * Get the friendly name associated with the input class.
  45009. * @returns the input friendly name
  45010. */
  45011. getSimpleName(): string;
  45012. }
  45013. }
  45014. declare module BABYLON {
  45015. /**
  45016. * Defines the potential axis of a Joystick
  45017. */
  45018. export enum JoystickAxis {
  45019. /** X axis */
  45020. X = 0,
  45021. /** Y axis */
  45022. Y = 1,
  45023. /** Z axis */
  45024. Z = 2
  45025. }
  45026. /**
  45027. * Represents the different customization options available
  45028. * for VirtualJoystick
  45029. */
  45030. interface VirtualJoystickCustomizations {
  45031. /**
  45032. * Size of the joystick's puck
  45033. */
  45034. puckSize: number;
  45035. /**
  45036. * Size of the joystick's container
  45037. */
  45038. containerSize: number;
  45039. /**
  45040. * Color of the joystick && puck
  45041. */
  45042. color: string;
  45043. /**
  45044. * Image URL for the joystick's puck
  45045. */
  45046. puckImage?: string;
  45047. /**
  45048. * Image URL for the joystick's container
  45049. */
  45050. containerImage?: string;
  45051. /**
  45052. * Defines the unmoving position of the joystick container
  45053. */
  45054. position?: {
  45055. x: number;
  45056. y: number;
  45057. };
  45058. /**
  45059. * Defines whether or not the joystick container is always visible
  45060. */
  45061. alwaysVisible: boolean;
  45062. /**
  45063. * Defines whether or not to limit the movement of the puck to the joystick's container
  45064. */
  45065. limitToContainer: boolean;
  45066. }
  45067. /**
  45068. * Class used to define virtual joystick (used in touch mode)
  45069. */
  45070. export class VirtualJoystick {
  45071. /**
  45072. * Gets or sets a boolean indicating that left and right values must be inverted
  45073. */
  45074. reverseLeftRight: boolean;
  45075. /**
  45076. * Gets or sets a boolean indicating that up and down values must be inverted
  45077. */
  45078. reverseUpDown: boolean;
  45079. /**
  45080. * Gets the offset value for the position (ie. the change of the position value)
  45081. */
  45082. deltaPosition: Vector3;
  45083. /**
  45084. * Gets a boolean indicating if the virtual joystick was pressed
  45085. */
  45086. pressed: boolean;
  45087. /**
  45088. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45089. */
  45090. static Canvas: Nullable<HTMLCanvasElement>;
  45091. /**
  45092. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45093. */
  45094. limitToContainer: boolean;
  45095. private static _globalJoystickIndex;
  45096. private static _alwaysVisibleSticks;
  45097. private static vjCanvasContext;
  45098. private static vjCanvasWidth;
  45099. private static vjCanvasHeight;
  45100. private static halfWidth;
  45101. private static _GetDefaultOptions;
  45102. private _action;
  45103. private _axisTargetedByLeftAndRight;
  45104. private _axisTargetedByUpAndDown;
  45105. private _joystickSensibility;
  45106. private _inversedSensibility;
  45107. private _joystickPointerID;
  45108. private _joystickColor;
  45109. private _joystickPointerPos;
  45110. private _joystickPreviousPointerPos;
  45111. private _joystickPointerStartPos;
  45112. private _deltaJoystickVector;
  45113. private _leftJoystick;
  45114. private _touches;
  45115. private _joystickPosition;
  45116. private _alwaysVisible;
  45117. private _puckImage;
  45118. private _containerImage;
  45119. private _joystickPuckSize;
  45120. private _joystickContainerSize;
  45121. private _clearPuckSize;
  45122. private _clearContainerSize;
  45123. private _clearPuckSizeOffset;
  45124. private _clearContainerSizeOffset;
  45125. private _onPointerDownHandlerRef;
  45126. private _onPointerMoveHandlerRef;
  45127. private _onPointerUpHandlerRef;
  45128. private _onResize;
  45129. /**
  45130. * Creates a new virtual joystick
  45131. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45132. * @param customizations Defines the options we want to customize the VirtualJoystick
  45133. */
  45134. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45135. /**
  45136. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45137. * @param newJoystickSensibility defines the new sensibility
  45138. */
  45139. setJoystickSensibility(newJoystickSensibility: number): void;
  45140. private _onPointerDown;
  45141. private _onPointerMove;
  45142. private _onPointerUp;
  45143. /**
  45144. * Change the color of the virtual joystick
  45145. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45146. */
  45147. setJoystickColor(newColor: string): void;
  45148. /**
  45149. * Size of the joystick's container
  45150. */
  45151. set containerSize(newSize: number);
  45152. get containerSize(): number;
  45153. /**
  45154. * Size of the joystick's puck
  45155. */
  45156. set puckSize(newSize: number);
  45157. get puckSize(): number;
  45158. /**
  45159. * Clears the set position of the joystick
  45160. */
  45161. clearPosition(): void;
  45162. /**
  45163. * Defines whether or not the joystick container is always visible
  45164. */
  45165. set alwaysVisible(value: boolean);
  45166. get alwaysVisible(): boolean;
  45167. /**
  45168. * Sets the constant position of the Joystick container
  45169. * @param x X axis coordinate
  45170. * @param y Y axis coordinate
  45171. */
  45172. setPosition(x: number, y: number): void;
  45173. /**
  45174. * Defines a callback to call when the joystick is touched
  45175. * @param action defines the callback
  45176. */
  45177. setActionOnTouch(action: () => any): void;
  45178. /**
  45179. * Defines which axis you'd like to control for left & right
  45180. * @param axis defines the axis to use
  45181. */
  45182. setAxisForLeftRight(axis: JoystickAxis): void;
  45183. /**
  45184. * Defines which axis you'd like to control for up & down
  45185. * @param axis defines the axis to use
  45186. */
  45187. setAxisForUpDown(axis: JoystickAxis): void;
  45188. /**
  45189. * Clears the canvas from the previous puck / container draw
  45190. */
  45191. private _clearPreviousDraw;
  45192. /**
  45193. * Loads `urlPath` to be used for the container's image
  45194. * @param urlPath defines the urlPath of an image to use
  45195. */
  45196. setContainerImage(urlPath: string): void;
  45197. /**
  45198. * Loads `urlPath` to be used for the puck's image
  45199. * @param urlPath defines the urlPath of an image to use
  45200. */
  45201. setPuckImage(urlPath: string): void;
  45202. /**
  45203. * Draws the Virtual Joystick's container
  45204. */
  45205. private _drawContainer;
  45206. /**
  45207. * Draws the Virtual Joystick's puck
  45208. */
  45209. private _drawPuck;
  45210. private _drawVirtualJoystick;
  45211. /**
  45212. * Release internal HTML canvas
  45213. */
  45214. releaseCanvas(): void;
  45215. }
  45216. }
  45217. declare module BABYLON {
  45218. interface FreeCameraInputsManager {
  45219. /**
  45220. * Add virtual joystick input support to the input manager.
  45221. * @returns the current input manager
  45222. */
  45223. addVirtualJoystick(): FreeCameraInputsManager;
  45224. }
  45225. /**
  45226. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45227. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45228. */
  45229. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45230. /**
  45231. * Defines the camera the input is attached to.
  45232. */
  45233. camera: FreeCamera;
  45234. private _leftjoystick;
  45235. private _rightjoystick;
  45236. /**
  45237. * Gets the left stick of the virtual joystick.
  45238. * @returns The virtual Joystick
  45239. */
  45240. getLeftJoystick(): VirtualJoystick;
  45241. /**
  45242. * Gets the right stick of the virtual joystick.
  45243. * @returns The virtual Joystick
  45244. */
  45245. getRightJoystick(): VirtualJoystick;
  45246. /**
  45247. * Update the current camera state depending on the inputs that have been used this frame.
  45248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45249. */
  45250. checkInputs(): void;
  45251. /**
  45252. * Attach the input controls to a specific dom element to get the input from.
  45253. * @param element Defines the element the controls should be listened from
  45254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45255. */
  45256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45257. /**
  45258. * Detach the current controls from the specified dom element.
  45259. * @param element Defines the element to stop listening the inputs from
  45260. */
  45261. detachControl(element: Nullable<HTMLElement>): void;
  45262. /**
  45263. * Gets the class name of the current intput.
  45264. * @returns the class name
  45265. */
  45266. getClassName(): string;
  45267. /**
  45268. * Get the friendly name associated with the input class.
  45269. * @returns the input friendly name
  45270. */
  45271. getSimpleName(): string;
  45272. }
  45273. }
  45274. declare module BABYLON {
  45275. /**
  45276. * This represents a FPS type of camera controlled by touch.
  45277. * This is like a universal camera minus the Gamepad controls.
  45278. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45279. */
  45280. export class TouchCamera extends FreeCamera {
  45281. /**
  45282. * Defines the touch sensibility for rotation.
  45283. * The higher the faster.
  45284. */
  45285. get touchAngularSensibility(): number;
  45286. set touchAngularSensibility(value: number);
  45287. /**
  45288. * Defines the touch sensibility for move.
  45289. * The higher the faster.
  45290. */
  45291. get touchMoveSensibility(): number;
  45292. set touchMoveSensibility(value: number);
  45293. /**
  45294. * Instantiates a new touch camera.
  45295. * This represents a FPS type of camera controlled by touch.
  45296. * This is like a universal camera minus the Gamepad controls.
  45297. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45298. * @param name Define the name of the camera in the scene
  45299. * @param position Define the start position of the camera in the scene
  45300. * @param scene Define the scene the camera belongs to
  45301. */
  45302. constructor(name: string, position: Vector3, scene: Scene);
  45303. /**
  45304. * Gets the current object class name.
  45305. * @return the class name
  45306. */
  45307. getClassName(): string;
  45308. /** @hidden */
  45309. _setupInputs(): void;
  45310. }
  45311. }
  45312. declare module BABYLON {
  45313. /**
  45314. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45315. * being tilted forward or back and left or right.
  45316. */
  45317. export class DeviceOrientationCamera extends FreeCamera {
  45318. private _initialQuaternion;
  45319. private _quaternionCache;
  45320. private _tmpDragQuaternion;
  45321. private _disablePointerInputWhenUsingDeviceOrientation;
  45322. /**
  45323. * Creates a new device orientation camera
  45324. * @param name The name of the camera
  45325. * @param position The start position camera
  45326. * @param scene The scene the camera belongs to
  45327. */
  45328. constructor(name: string, position: Vector3, scene: Scene);
  45329. /**
  45330. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45331. */
  45332. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45333. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45334. private _dragFactor;
  45335. /**
  45336. * Enabled turning on the y axis when the orientation sensor is active
  45337. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45338. */
  45339. enableHorizontalDragging(dragFactor?: number): void;
  45340. /**
  45341. * Gets the current instance class name ("DeviceOrientationCamera").
  45342. * This helps avoiding instanceof at run time.
  45343. * @returns the class name
  45344. */
  45345. getClassName(): string;
  45346. /**
  45347. * @hidden
  45348. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45349. */
  45350. _checkInputs(): void;
  45351. /**
  45352. * Reset the camera to its default orientation on the specified axis only.
  45353. * @param axis The axis to reset
  45354. */
  45355. resetToCurrentRotation(axis?: Axis): void;
  45356. }
  45357. }
  45358. declare module BABYLON {
  45359. /**
  45360. * Defines supported buttons for XBox360 compatible gamepads
  45361. */
  45362. export enum Xbox360Button {
  45363. /** A */
  45364. A = 0,
  45365. /** B */
  45366. B = 1,
  45367. /** X */
  45368. X = 2,
  45369. /** Y */
  45370. Y = 3,
  45371. /** Left button */
  45372. LB = 4,
  45373. /** Right button */
  45374. RB = 5,
  45375. /** Back */
  45376. Back = 8,
  45377. /** Start */
  45378. Start = 9,
  45379. /** Left stick */
  45380. LeftStick = 10,
  45381. /** Right stick */
  45382. RightStick = 11
  45383. }
  45384. /** Defines values for XBox360 DPad */
  45385. export enum Xbox360Dpad {
  45386. /** Up */
  45387. Up = 12,
  45388. /** Down */
  45389. Down = 13,
  45390. /** Left */
  45391. Left = 14,
  45392. /** Right */
  45393. Right = 15
  45394. }
  45395. /**
  45396. * Defines a XBox360 gamepad
  45397. */
  45398. export class Xbox360Pad extends Gamepad {
  45399. private _leftTrigger;
  45400. private _rightTrigger;
  45401. private _onlefttriggerchanged;
  45402. private _onrighttriggerchanged;
  45403. private _onbuttondown;
  45404. private _onbuttonup;
  45405. private _ondpaddown;
  45406. private _ondpadup;
  45407. /** Observable raised when a button is pressed */
  45408. onButtonDownObservable: Observable<Xbox360Button>;
  45409. /** Observable raised when a button is released */
  45410. onButtonUpObservable: Observable<Xbox360Button>;
  45411. /** Observable raised when a pad is pressed */
  45412. onPadDownObservable: Observable<Xbox360Dpad>;
  45413. /** Observable raised when a pad is released */
  45414. onPadUpObservable: Observable<Xbox360Dpad>;
  45415. private _buttonA;
  45416. private _buttonB;
  45417. private _buttonX;
  45418. private _buttonY;
  45419. private _buttonBack;
  45420. private _buttonStart;
  45421. private _buttonLB;
  45422. private _buttonRB;
  45423. private _buttonLeftStick;
  45424. private _buttonRightStick;
  45425. private _dPadUp;
  45426. private _dPadDown;
  45427. private _dPadLeft;
  45428. private _dPadRight;
  45429. private _isXboxOnePad;
  45430. /**
  45431. * Creates a new XBox360 gamepad object
  45432. * @param id defines the id of this gamepad
  45433. * @param index defines its index
  45434. * @param gamepad defines the internal HTML gamepad object
  45435. * @param xboxOne defines if it is a XBox One gamepad
  45436. */
  45437. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45438. /**
  45439. * Defines the callback to call when left trigger is pressed
  45440. * @param callback defines the callback to use
  45441. */
  45442. onlefttriggerchanged(callback: (value: number) => void): void;
  45443. /**
  45444. * Defines the callback to call when right trigger is pressed
  45445. * @param callback defines the callback to use
  45446. */
  45447. onrighttriggerchanged(callback: (value: number) => void): void;
  45448. /**
  45449. * Gets the left trigger value
  45450. */
  45451. get leftTrigger(): number;
  45452. /**
  45453. * Sets the left trigger value
  45454. */
  45455. set leftTrigger(newValue: number);
  45456. /**
  45457. * Gets the right trigger value
  45458. */
  45459. get rightTrigger(): number;
  45460. /**
  45461. * Sets the right trigger value
  45462. */
  45463. set rightTrigger(newValue: number);
  45464. /**
  45465. * Defines the callback to call when a button is pressed
  45466. * @param callback defines the callback to use
  45467. */
  45468. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45469. /**
  45470. * Defines the callback to call when a button is released
  45471. * @param callback defines the callback to use
  45472. */
  45473. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45474. /**
  45475. * Defines the callback to call when a pad is pressed
  45476. * @param callback defines the callback to use
  45477. */
  45478. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45479. /**
  45480. * Defines the callback to call when a pad is released
  45481. * @param callback defines the callback to use
  45482. */
  45483. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45484. private _setButtonValue;
  45485. private _setDPadValue;
  45486. /**
  45487. * Gets the value of the `A` button
  45488. */
  45489. get buttonA(): number;
  45490. /**
  45491. * Sets the value of the `A` button
  45492. */
  45493. set buttonA(value: number);
  45494. /**
  45495. * Gets the value of the `B` button
  45496. */
  45497. get buttonB(): number;
  45498. /**
  45499. * Sets the value of the `B` button
  45500. */
  45501. set buttonB(value: number);
  45502. /**
  45503. * Gets the value of the `X` button
  45504. */
  45505. get buttonX(): number;
  45506. /**
  45507. * Sets the value of the `X` button
  45508. */
  45509. set buttonX(value: number);
  45510. /**
  45511. * Gets the value of the `Y` button
  45512. */
  45513. get buttonY(): number;
  45514. /**
  45515. * Sets the value of the `Y` button
  45516. */
  45517. set buttonY(value: number);
  45518. /**
  45519. * Gets the value of the `Start` button
  45520. */
  45521. get buttonStart(): number;
  45522. /**
  45523. * Sets the value of the `Start` button
  45524. */
  45525. set buttonStart(value: number);
  45526. /**
  45527. * Gets the value of the `Back` button
  45528. */
  45529. get buttonBack(): number;
  45530. /**
  45531. * Sets the value of the `Back` button
  45532. */
  45533. set buttonBack(value: number);
  45534. /**
  45535. * Gets the value of the `Left` button
  45536. */
  45537. get buttonLB(): number;
  45538. /**
  45539. * Sets the value of the `Left` button
  45540. */
  45541. set buttonLB(value: number);
  45542. /**
  45543. * Gets the value of the `Right` button
  45544. */
  45545. get buttonRB(): number;
  45546. /**
  45547. * Sets the value of the `Right` button
  45548. */
  45549. set buttonRB(value: number);
  45550. /**
  45551. * Gets the value of the Left joystick
  45552. */
  45553. get buttonLeftStick(): number;
  45554. /**
  45555. * Sets the value of the Left joystick
  45556. */
  45557. set buttonLeftStick(value: number);
  45558. /**
  45559. * Gets the value of the Right joystick
  45560. */
  45561. get buttonRightStick(): number;
  45562. /**
  45563. * Sets the value of the Right joystick
  45564. */
  45565. set buttonRightStick(value: number);
  45566. /**
  45567. * Gets the value of D-pad up
  45568. */
  45569. get dPadUp(): number;
  45570. /**
  45571. * Sets the value of D-pad up
  45572. */
  45573. set dPadUp(value: number);
  45574. /**
  45575. * Gets the value of D-pad down
  45576. */
  45577. get dPadDown(): number;
  45578. /**
  45579. * Sets the value of D-pad down
  45580. */
  45581. set dPadDown(value: number);
  45582. /**
  45583. * Gets the value of D-pad left
  45584. */
  45585. get dPadLeft(): number;
  45586. /**
  45587. * Sets the value of D-pad left
  45588. */
  45589. set dPadLeft(value: number);
  45590. /**
  45591. * Gets the value of D-pad right
  45592. */
  45593. get dPadRight(): number;
  45594. /**
  45595. * Sets the value of D-pad right
  45596. */
  45597. set dPadRight(value: number);
  45598. /**
  45599. * Force the gamepad to synchronize with device values
  45600. */
  45601. update(): void;
  45602. /**
  45603. * Disposes the gamepad
  45604. */
  45605. dispose(): void;
  45606. }
  45607. }
  45608. declare module BABYLON {
  45609. /**
  45610. * Defines supported buttons for DualShock compatible gamepads
  45611. */
  45612. export enum DualShockButton {
  45613. /** Cross */
  45614. Cross = 0,
  45615. /** Circle */
  45616. Circle = 1,
  45617. /** Square */
  45618. Square = 2,
  45619. /** Triangle */
  45620. Triangle = 3,
  45621. /** L1 */
  45622. L1 = 4,
  45623. /** R1 */
  45624. R1 = 5,
  45625. /** Share */
  45626. Share = 8,
  45627. /** Options */
  45628. Options = 9,
  45629. /** Left stick */
  45630. LeftStick = 10,
  45631. /** Right stick */
  45632. RightStick = 11
  45633. }
  45634. /** Defines values for DualShock DPad */
  45635. export enum DualShockDpad {
  45636. /** Up */
  45637. Up = 12,
  45638. /** Down */
  45639. Down = 13,
  45640. /** Left */
  45641. Left = 14,
  45642. /** Right */
  45643. Right = 15
  45644. }
  45645. /**
  45646. * Defines a DualShock gamepad
  45647. */
  45648. export class DualShockPad extends Gamepad {
  45649. private _leftTrigger;
  45650. private _rightTrigger;
  45651. private _onlefttriggerchanged;
  45652. private _onrighttriggerchanged;
  45653. private _onbuttondown;
  45654. private _onbuttonup;
  45655. private _ondpaddown;
  45656. private _ondpadup;
  45657. /** Observable raised when a button is pressed */
  45658. onButtonDownObservable: Observable<DualShockButton>;
  45659. /** Observable raised when a button is released */
  45660. onButtonUpObservable: Observable<DualShockButton>;
  45661. /** Observable raised when a pad is pressed */
  45662. onPadDownObservable: Observable<DualShockDpad>;
  45663. /** Observable raised when a pad is released */
  45664. onPadUpObservable: Observable<DualShockDpad>;
  45665. private _buttonCross;
  45666. private _buttonCircle;
  45667. private _buttonSquare;
  45668. private _buttonTriangle;
  45669. private _buttonShare;
  45670. private _buttonOptions;
  45671. private _buttonL1;
  45672. private _buttonR1;
  45673. private _buttonLeftStick;
  45674. private _buttonRightStick;
  45675. private _dPadUp;
  45676. private _dPadDown;
  45677. private _dPadLeft;
  45678. private _dPadRight;
  45679. /**
  45680. * Creates a new DualShock gamepad object
  45681. * @param id defines the id of this gamepad
  45682. * @param index defines its index
  45683. * @param gamepad defines the internal HTML gamepad object
  45684. */
  45685. constructor(id: string, index: number, gamepad: any);
  45686. /**
  45687. * Defines the callback to call when left trigger is pressed
  45688. * @param callback defines the callback to use
  45689. */
  45690. onlefttriggerchanged(callback: (value: number) => void): void;
  45691. /**
  45692. * Defines the callback to call when right trigger is pressed
  45693. * @param callback defines the callback to use
  45694. */
  45695. onrighttriggerchanged(callback: (value: number) => void): void;
  45696. /**
  45697. * Gets the left trigger value
  45698. */
  45699. get leftTrigger(): number;
  45700. /**
  45701. * Sets the left trigger value
  45702. */
  45703. set leftTrigger(newValue: number);
  45704. /**
  45705. * Gets the right trigger value
  45706. */
  45707. get rightTrigger(): number;
  45708. /**
  45709. * Sets the right trigger value
  45710. */
  45711. set rightTrigger(newValue: number);
  45712. /**
  45713. * Defines the callback to call when a button is pressed
  45714. * @param callback defines the callback to use
  45715. */
  45716. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45717. /**
  45718. * Defines the callback to call when a button is released
  45719. * @param callback defines the callback to use
  45720. */
  45721. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45722. /**
  45723. * Defines the callback to call when a pad is pressed
  45724. * @param callback defines the callback to use
  45725. */
  45726. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45727. /**
  45728. * Defines the callback to call when a pad is released
  45729. * @param callback defines the callback to use
  45730. */
  45731. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45732. private _setButtonValue;
  45733. private _setDPadValue;
  45734. /**
  45735. * Gets the value of the `Cross` button
  45736. */
  45737. get buttonCross(): number;
  45738. /**
  45739. * Sets the value of the `Cross` button
  45740. */
  45741. set buttonCross(value: number);
  45742. /**
  45743. * Gets the value of the `Circle` button
  45744. */
  45745. get buttonCircle(): number;
  45746. /**
  45747. * Sets the value of the `Circle` button
  45748. */
  45749. set buttonCircle(value: number);
  45750. /**
  45751. * Gets the value of the `Square` button
  45752. */
  45753. get buttonSquare(): number;
  45754. /**
  45755. * Sets the value of the `Square` button
  45756. */
  45757. set buttonSquare(value: number);
  45758. /**
  45759. * Gets the value of the `Triangle` button
  45760. */
  45761. get buttonTriangle(): number;
  45762. /**
  45763. * Sets the value of the `Triangle` button
  45764. */
  45765. set buttonTriangle(value: number);
  45766. /**
  45767. * Gets the value of the `Options` button
  45768. */
  45769. get buttonOptions(): number;
  45770. /**
  45771. * Sets the value of the `Options` button
  45772. */
  45773. set buttonOptions(value: number);
  45774. /**
  45775. * Gets the value of the `Share` button
  45776. */
  45777. get buttonShare(): number;
  45778. /**
  45779. * Sets the value of the `Share` button
  45780. */
  45781. set buttonShare(value: number);
  45782. /**
  45783. * Gets the value of the `L1` button
  45784. */
  45785. get buttonL1(): number;
  45786. /**
  45787. * Sets the value of the `L1` button
  45788. */
  45789. set buttonL1(value: number);
  45790. /**
  45791. * Gets the value of the `R1` button
  45792. */
  45793. get buttonR1(): number;
  45794. /**
  45795. * Sets the value of the `R1` button
  45796. */
  45797. set buttonR1(value: number);
  45798. /**
  45799. * Gets the value of the Left joystick
  45800. */
  45801. get buttonLeftStick(): number;
  45802. /**
  45803. * Sets the value of the Left joystick
  45804. */
  45805. set buttonLeftStick(value: number);
  45806. /**
  45807. * Gets the value of the Right joystick
  45808. */
  45809. get buttonRightStick(): number;
  45810. /**
  45811. * Sets the value of the Right joystick
  45812. */
  45813. set buttonRightStick(value: number);
  45814. /**
  45815. * Gets the value of D-pad up
  45816. */
  45817. get dPadUp(): number;
  45818. /**
  45819. * Sets the value of D-pad up
  45820. */
  45821. set dPadUp(value: number);
  45822. /**
  45823. * Gets the value of D-pad down
  45824. */
  45825. get dPadDown(): number;
  45826. /**
  45827. * Sets the value of D-pad down
  45828. */
  45829. set dPadDown(value: number);
  45830. /**
  45831. * Gets the value of D-pad left
  45832. */
  45833. get dPadLeft(): number;
  45834. /**
  45835. * Sets the value of D-pad left
  45836. */
  45837. set dPadLeft(value: number);
  45838. /**
  45839. * Gets the value of D-pad right
  45840. */
  45841. get dPadRight(): number;
  45842. /**
  45843. * Sets the value of D-pad right
  45844. */
  45845. set dPadRight(value: number);
  45846. /**
  45847. * Force the gamepad to synchronize with device values
  45848. */
  45849. update(): void;
  45850. /**
  45851. * Disposes the gamepad
  45852. */
  45853. dispose(): void;
  45854. }
  45855. }
  45856. declare module BABYLON {
  45857. /**
  45858. * Manager for handling gamepads
  45859. */
  45860. export class GamepadManager {
  45861. private _scene?;
  45862. private _babylonGamepads;
  45863. private _oneGamepadConnected;
  45864. /** @hidden */
  45865. _isMonitoring: boolean;
  45866. private _gamepadEventSupported;
  45867. private _gamepadSupport?;
  45868. /**
  45869. * observable to be triggered when the gamepad controller has been connected
  45870. */
  45871. onGamepadConnectedObservable: Observable<Gamepad>;
  45872. /**
  45873. * observable to be triggered when the gamepad controller has been disconnected
  45874. */
  45875. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45876. private _onGamepadConnectedEvent;
  45877. private _onGamepadDisconnectedEvent;
  45878. /**
  45879. * Initializes the gamepad manager
  45880. * @param _scene BabylonJS scene
  45881. */
  45882. constructor(_scene?: Scene | undefined);
  45883. /**
  45884. * The gamepads in the game pad manager
  45885. */
  45886. get gamepads(): Gamepad[];
  45887. /**
  45888. * Get the gamepad controllers based on type
  45889. * @param type The type of gamepad controller
  45890. * @returns Nullable gamepad
  45891. */
  45892. getGamepadByType(type?: number): Nullable<Gamepad>;
  45893. /**
  45894. * Disposes the gamepad manager
  45895. */
  45896. dispose(): void;
  45897. private _addNewGamepad;
  45898. private _startMonitoringGamepads;
  45899. private _stopMonitoringGamepads;
  45900. /** @hidden */
  45901. _checkGamepadsStatus(): void;
  45902. private _updateGamepadObjects;
  45903. }
  45904. }
  45905. declare module BABYLON {
  45906. interface Scene {
  45907. /** @hidden */
  45908. _gamepadManager: Nullable<GamepadManager>;
  45909. /**
  45910. * Gets the gamepad manager associated with the scene
  45911. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45912. */
  45913. gamepadManager: GamepadManager;
  45914. }
  45915. /**
  45916. * Interface representing a free camera inputs manager
  45917. */
  45918. interface FreeCameraInputsManager {
  45919. /**
  45920. * Adds gamepad input support to the FreeCameraInputsManager.
  45921. * @returns the FreeCameraInputsManager
  45922. */
  45923. addGamepad(): FreeCameraInputsManager;
  45924. }
  45925. /**
  45926. * Interface representing an arc rotate camera inputs manager
  45927. */
  45928. interface ArcRotateCameraInputsManager {
  45929. /**
  45930. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45931. * @returns the camera inputs manager
  45932. */
  45933. addGamepad(): ArcRotateCameraInputsManager;
  45934. }
  45935. /**
  45936. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45937. */
  45938. export class GamepadSystemSceneComponent implements ISceneComponent {
  45939. /**
  45940. * The component name helpfull to identify the component in the list of scene components.
  45941. */
  45942. readonly name: string;
  45943. /**
  45944. * The scene the component belongs to.
  45945. */
  45946. scene: Scene;
  45947. /**
  45948. * Creates a new instance of the component for the given scene
  45949. * @param scene Defines the scene to register the component in
  45950. */
  45951. constructor(scene: Scene);
  45952. /**
  45953. * Registers the component in a given scene
  45954. */
  45955. register(): void;
  45956. /**
  45957. * Rebuilds the elements related to this component in case of
  45958. * context lost for instance.
  45959. */
  45960. rebuild(): void;
  45961. /**
  45962. * Disposes the component and the associated ressources
  45963. */
  45964. dispose(): void;
  45965. private _beforeCameraUpdate;
  45966. }
  45967. }
  45968. declare module BABYLON {
  45969. /**
  45970. * 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,
  45971. * which still works and will still be found in many Playgrounds.
  45972. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45973. */
  45974. export class UniversalCamera extends TouchCamera {
  45975. /**
  45976. * Defines the gamepad rotation sensiblity.
  45977. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45978. */
  45979. get gamepadAngularSensibility(): number;
  45980. set gamepadAngularSensibility(value: number);
  45981. /**
  45982. * Defines the gamepad move sensiblity.
  45983. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45984. */
  45985. get gamepadMoveSensibility(): number;
  45986. set gamepadMoveSensibility(value: number);
  45987. /**
  45988. * 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,
  45989. * which still works and will still be found in many Playgrounds.
  45990. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45991. * @param name Define the name of the camera in the scene
  45992. * @param position Define the start position of the camera in the scene
  45993. * @param scene Define the scene the camera belongs to
  45994. */
  45995. constructor(name: string, position: Vector3, scene: Scene);
  45996. /**
  45997. * Gets the current object class name.
  45998. * @return the class name
  45999. */
  46000. getClassName(): string;
  46001. }
  46002. }
  46003. declare module BABYLON {
  46004. /**
  46005. * This represents a FPS type of camera. This is only here for back compat purpose.
  46006. * Please use the UniversalCamera instead as both are identical.
  46007. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46008. */
  46009. export class GamepadCamera extends UniversalCamera {
  46010. /**
  46011. * Instantiates a new Gamepad Camera
  46012. * This represents a FPS type of camera. This is only here for back compat purpose.
  46013. * Please use the UniversalCamera instead as both are identical.
  46014. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46015. * @param name Define the name of the camera in the scene
  46016. * @param position Define the start position of the camera in the scene
  46017. * @param scene Define the scene the camera belongs to
  46018. */
  46019. constructor(name: string, position: Vector3, scene: Scene);
  46020. /**
  46021. * Gets the current object class name.
  46022. * @return the class name
  46023. */
  46024. getClassName(): string;
  46025. }
  46026. }
  46027. declare module BABYLON {
  46028. /** @hidden */
  46029. export var passPixelShader: {
  46030. name: string;
  46031. shader: string;
  46032. };
  46033. }
  46034. declare module BABYLON {
  46035. /** @hidden */
  46036. export var passCubePixelShader: {
  46037. name: string;
  46038. shader: string;
  46039. };
  46040. }
  46041. declare module BABYLON {
  46042. /**
  46043. * PassPostProcess which produces an output the same as it's input
  46044. */
  46045. export class PassPostProcess extends PostProcess {
  46046. /**
  46047. * Gets a string identifying the name of the class
  46048. * @returns "PassPostProcess" string
  46049. */
  46050. getClassName(): string;
  46051. /**
  46052. * Creates the PassPostProcess
  46053. * @param name The name of the effect.
  46054. * @param options The required width/height ratio to downsize to before computing the render pass.
  46055. * @param camera The camera to apply the render pass to.
  46056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46057. * @param engine The engine which the post process will be applied. (default: current engine)
  46058. * @param reusable If the post process can be reused on the same frame. (default: false)
  46059. * @param textureType The type of texture to be used when performing the post processing.
  46060. * @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)
  46061. */
  46062. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46063. /** @hidden */
  46064. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46065. }
  46066. /**
  46067. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46068. */
  46069. export class PassCubePostProcess extends PostProcess {
  46070. private _face;
  46071. /**
  46072. * Gets or sets the cube face to display.
  46073. * * 0 is +X
  46074. * * 1 is -X
  46075. * * 2 is +Y
  46076. * * 3 is -Y
  46077. * * 4 is +Z
  46078. * * 5 is -Z
  46079. */
  46080. get face(): number;
  46081. set face(value: number);
  46082. /**
  46083. * Gets a string identifying the name of the class
  46084. * @returns "PassCubePostProcess" string
  46085. */
  46086. getClassName(): string;
  46087. /**
  46088. * Creates the PassCubePostProcess
  46089. * @param name The name of the effect.
  46090. * @param options The required width/height ratio to downsize to before computing the render pass.
  46091. * @param camera The camera to apply the render pass to.
  46092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46093. * @param engine The engine which the post process will be applied. (default: current engine)
  46094. * @param reusable If the post process can be reused on the same frame. (default: false)
  46095. * @param textureType The type of texture to be used when performing the post processing.
  46096. * @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)
  46097. */
  46098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46099. /** @hidden */
  46100. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46101. }
  46102. }
  46103. declare module BABYLON {
  46104. /** @hidden */
  46105. export var anaglyphPixelShader: {
  46106. name: string;
  46107. shader: string;
  46108. };
  46109. }
  46110. declare module BABYLON {
  46111. /**
  46112. * Postprocess used to generate anaglyphic rendering
  46113. */
  46114. export class AnaglyphPostProcess extends PostProcess {
  46115. private _passedProcess;
  46116. /**
  46117. * Gets a string identifying the name of the class
  46118. * @returns "AnaglyphPostProcess" string
  46119. */
  46120. getClassName(): string;
  46121. /**
  46122. * Creates a new AnaglyphPostProcess
  46123. * @param name defines postprocess name
  46124. * @param options defines creation options or target ratio scale
  46125. * @param rigCameras defines cameras using this postprocess
  46126. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46127. * @param engine defines hosting engine
  46128. * @param reusable defines if the postprocess will be reused multiple times per frame
  46129. */
  46130. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46131. }
  46132. }
  46133. declare module BABYLON {
  46134. /**
  46135. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46136. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46137. */
  46138. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46139. /**
  46140. * Creates a new AnaglyphArcRotateCamera
  46141. * @param name defines camera name
  46142. * @param alpha defines alpha angle (in radians)
  46143. * @param beta defines beta angle (in radians)
  46144. * @param radius defines radius
  46145. * @param target defines camera target
  46146. * @param interaxialDistance defines distance between each color axis
  46147. * @param scene defines the hosting scene
  46148. */
  46149. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46150. /**
  46151. * Gets camera class name
  46152. * @returns AnaglyphArcRotateCamera
  46153. */
  46154. getClassName(): string;
  46155. }
  46156. }
  46157. declare module BABYLON {
  46158. /**
  46159. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46160. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46161. */
  46162. export class AnaglyphFreeCamera extends FreeCamera {
  46163. /**
  46164. * Creates a new AnaglyphFreeCamera
  46165. * @param name defines camera name
  46166. * @param position defines initial position
  46167. * @param interaxialDistance defines distance between each color axis
  46168. * @param scene defines the hosting scene
  46169. */
  46170. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46171. /**
  46172. * Gets camera class name
  46173. * @returns AnaglyphFreeCamera
  46174. */
  46175. getClassName(): string;
  46176. }
  46177. }
  46178. declare module BABYLON {
  46179. /**
  46180. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46181. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46182. */
  46183. export class AnaglyphGamepadCamera extends GamepadCamera {
  46184. /**
  46185. * Creates a new AnaglyphGamepadCamera
  46186. * @param name defines camera name
  46187. * @param position defines initial position
  46188. * @param interaxialDistance defines distance between each color axis
  46189. * @param scene defines the hosting scene
  46190. */
  46191. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46192. /**
  46193. * Gets camera class name
  46194. * @returns AnaglyphGamepadCamera
  46195. */
  46196. getClassName(): string;
  46197. }
  46198. }
  46199. declare module BABYLON {
  46200. /**
  46201. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46202. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46203. */
  46204. export class AnaglyphUniversalCamera extends UniversalCamera {
  46205. /**
  46206. * Creates a new AnaglyphUniversalCamera
  46207. * @param name defines camera name
  46208. * @param position defines initial position
  46209. * @param interaxialDistance defines distance between each color axis
  46210. * @param scene defines the hosting scene
  46211. */
  46212. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46213. /**
  46214. * Gets camera class name
  46215. * @returns AnaglyphUniversalCamera
  46216. */
  46217. getClassName(): string;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /**
  46222. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46223. * @see https://doc.babylonjs.com/features/cameras
  46224. */
  46225. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46226. /**
  46227. * Creates a new StereoscopicArcRotateCamera
  46228. * @param name defines camera name
  46229. * @param alpha defines alpha angle (in radians)
  46230. * @param beta defines beta angle (in radians)
  46231. * @param radius defines radius
  46232. * @param target defines camera target
  46233. * @param interaxialDistance defines distance between each color axis
  46234. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46235. * @param scene defines the hosting scene
  46236. */
  46237. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46238. /**
  46239. * Gets camera class name
  46240. * @returns StereoscopicArcRotateCamera
  46241. */
  46242. getClassName(): string;
  46243. }
  46244. }
  46245. declare module BABYLON {
  46246. /**
  46247. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46248. * @see https://doc.babylonjs.com/features/cameras
  46249. */
  46250. export class StereoscopicFreeCamera extends FreeCamera {
  46251. /**
  46252. * Creates a new StereoscopicFreeCamera
  46253. * @param name defines camera name
  46254. * @param position defines initial position
  46255. * @param interaxialDistance defines distance between each color axis
  46256. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46257. * @param scene defines the hosting scene
  46258. */
  46259. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46260. /**
  46261. * Gets camera class name
  46262. * @returns StereoscopicFreeCamera
  46263. */
  46264. getClassName(): string;
  46265. }
  46266. }
  46267. declare module BABYLON {
  46268. /**
  46269. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46270. * @see https://doc.babylonjs.com/features/cameras
  46271. */
  46272. export class StereoscopicGamepadCamera extends GamepadCamera {
  46273. /**
  46274. * Creates a new StereoscopicGamepadCamera
  46275. * @param name defines camera name
  46276. * @param position defines initial position
  46277. * @param interaxialDistance defines distance between each color axis
  46278. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46279. * @param scene defines the hosting scene
  46280. */
  46281. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46282. /**
  46283. * Gets camera class name
  46284. * @returns StereoscopicGamepadCamera
  46285. */
  46286. getClassName(): string;
  46287. }
  46288. }
  46289. declare module BABYLON {
  46290. /**
  46291. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46292. * @see https://doc.babylonjs.com/features/cameras
  46293. */
  46294. export class StereoscopicUniversalCamera extends UniversalCamera {
  46295. /**
  46296. * Creates a new StereoscopicUniversalCamera
  46297. * @param name defines camera name
  46298. * @param position defines initial position
  46299. * @param interaxialDistance defines distance between each color axis
  46300. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46301. * @param scene defines the hosting scene
  46302. */
  46303. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46304. /**
  46305. * Gets camera class name
  46306. * @returns StereoscopicUniversalCamera
  46307. */
  46308. getClassName(): string;
  46309. }
  46310. }
  46311. declare module BABYLON {
  46312. /**
  46313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46314. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46315. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46316. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46317. */
  46318. export class VirtualJoysticksCamera extends FreeCamera {
  46319. /**
  46320. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46321. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46322. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46323. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46324. * @param name Define the name of the camera in the scene
  46325. * @param position Define the start position of the camera in the scene
  46326. * @param scene Define the scene the camera belongs to
  46327. */
  46328. constructor(name: string, position: Vector3, scene: Scene);
  46329. /**
  46330. * Gets the current object class name.
  46331. * @return the class name
  46332. */
  46333. getClassName(): string;
  46334. }
  46335. }
  46336. declare module BABYLON {
  46337. /**
  46338. * This represents all the required metrics to create a VR camera.
  46339. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46340. */
  46341. export class VRCameraMetrics {
  46342. /**
  46343. * Define the horizontal resolution off the screen.
  46344. */
  46345. hResolution: number;
  46346. /**
  46347. * Define the vertical resolution off the screen.
  46348. */
  46349. vResolution: number;
  46350. /**
  46351. * Define the horizontal screen size.
  46352. */
  46353. hScreenSize: number;
  46354. /**
  46355. * Define the vertical screen size.
  46356. */
  46357. vScreenSize: number;
  46358. /**
  46359. * Define the vertical screen center position.
  46360. */
  46361. vScreenCenter: number;
  46362. /**
  46363. * Define the distance of the eyes to the screen.
  46364. */
  46365. eyeToScreenDistance: number;
  46366. /**
  46367. * Define the distance between both lenses
  46368. */
  46369. lensSeparationDistance: number;
  46370. /**
  46371. * Define the distance between both viewer's eyes.
  46372. */
  46373. interpupillaryDistance: number;
  46374. /**
  46375. * Define the distortion factor of the VR postprocess.
  46376. * Please, touch with care.
  46377. */
  46378. distortionK: number[];
  46379. /**
  46380. * Define the chromatic aberration correction factors for the VR post process.
  46381. */
  46382. chromaAbCorrection: number[];
  46383. /**
  46384. * Define the scale factor of the post process.
  46385. * The smaller the better but the slower.
  46386. */
  46387. postProcessScaleFactor: number;
  46388. /**
  46389. * Define an offset for the lens center.
  46390. */
  46391. lensCenterOffset: number;
  46392. /**
  46393. * Define if the current vr camera should compensate the distortion of the lense or not.
  46394. */
  46395. compensateDistortion: boolean;
  46396. /**
  46397. * Defines if multiview should be enabled when rendering (Default: false)
  46398. */
  46399. multiviewEnabled: boolean;
  46400. /**
  46401. * Gets the rendering aspect ratio based on the provided resolutions.
  46402. */
  46403. get aspectRatio(): number;
  46404. /**
  46405. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46406. */
  46407. get aspectRatioFov(): number;
  46408. /**
  46409. * @hidden
  46410. */
  46411. get leftHMatrix(): Matrix;
  46412. /**
  46413. * @hidden
  46414. */
  46415. get rightHMatrix(): Matrix;
  46416. /**
  46417. * @hidden
  46418. */
  46419. get leftPreViewMatrix(): Matrix;
  46420. /**
  46421. * @hidden
  46422. */
  46423. get rightPreViewMatrix(): Matrix;
  46424. /**
  46425. * Get the default VRMetrics based on the most generic setup.
  46426. * @returns the default vr metrics
  46427. */
  46428. static GetDefault(): VRCameraMetrics;
  46429. }
  46430. }
  46431. declare module BABYLON {
  46432. /** @hidden */
  46433. export var vrDistortionCorrectionPixelShader: {
  46434. name: string;
  46435. shader: string;
  46436. };
  46437. }
  46438. declare module BABYLON {
  46439. /**
  46440. * VRDistortionCorrectionPostProcess used for mobile VR
  46441. */
  46442. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46443. private _isRightEye;
  46444. private _distortionFactors;
  46445. private _postProcessScaleFactor;
  46446. private _lensCenterOffset;
  46447. private _scaleIn;
  46448. private _scaleFactor;
  46449. private _lensCenter;
  46450. /**
  46451. * Gets a string identifying the name of the class
  46452. * @returns "VRDistortionCorrectionPostProcess" string
  46453. */
  46454. getClassName(): string;
  46455. /**
  46456. * Initializes the VRDistortionCorrectionPostProcess
  46457. * @param name The name of the effect.
  46458. * @param camera The camera to apply the render pass to.
  46459. * @param isRightEye If this is for the right eye distortion
  46460. * @param vrMetrics All the required metrics for the VR camera
  46461. */
  46462. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46463. }
  46464. }
  46465. declare module BABYLON {
  46466. /**
  46467. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46468. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46469. */
  46470. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46471. /**
  46472. * Creates a new VRDeviceOrientationArcRotateCamera
  46473. * @param name defines camera name
  46474. * @param alpha defines the camera rotation along the logitudinal axis
  46475. * @param beta defines the camera rotation along the latitudinal axis
  46476. * @param radius defines the camera distance from its target
  46477. * @param target defines the camera target
  46478. * @param scene defines the scene the camera belongs to
  46479. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46480. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46481. */
  46482. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46483. /**
  46484. * Gets camera class name
  46485. * @returns VRDeviceOrientationArcRotateCamera
  46486. */
  46487. getClassName(): string;
  46488. }
  46489. }
  46490. declare module BABYLON {
  46491. /**
  46492. * Camera used to simulate VR rendering (based on FreeCamera)
  46493. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46494. */
  46495. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46496. /**
  46497. * Creates a new VRDeviceOrientationFreeCamera
  46498. * @param name defines camera name
  46499. * @param position defines the start position of the camera
  46500. * @param scene defines the scene the camera belongs to
  46501. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46502. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46503. */
  46504. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46505. /**
  46506. * Gets camera class name
  46507. * @returns VRDeviceOrientationFreeCamera
  46508. */
  46509. getClassName(): string;
  46510. }
  46511. }
  46512. declare module BABYLON {
  46513. /**
  46514. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46515. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46516. */
  46517. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46518. /**
  46519. * Creates a new VRDeviceOrientationGamepadCamera
  46520. * @param name defines camera name
  46521. * @param position defines the start position of the camera
  46522. * @param scene defines the scene the camera belongs to
  46523. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46524. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46525. */
  46526. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46527. /**
  46528. * Gets camera class name
  46529. * @returns VRDeviceOrientationGamepadCamera
  46530. */
  46531. getClassName(): string;
  46532. }
  46533. }
  46534. declare module BABYLON {
  46535. /**
  46536. * A class extending Texture allowing drawing on a texture
  46537. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46538. */
  46539. export class DynamicTexture extends Texture {
  46540. private _generateMipMaps;
  46541. private _canvas;
  46542. private _context;
  46543. /**
  46544. * Creates a DynamicTexture
  46545. * @param name defines the name of the texture
  46546. * @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
  46547. * @param scene defines the scene where you want the texture
  46548. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46549. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46550. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46551. */
  46552. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46553. /**
  46554. * Get the current class name of the texture useful for serialization or dynamic coding.
  46555. * @returns "DynamicTexture"
  46556. */
  46557. getClassName(): string;
  46558. /**
  46559. * Gets the current state of canRescale
  46560. */
  46561. get canRescale(): boolean;
  46562. private _recreate;
  46563. /**
  46564. * Scales the texture
  46565. * @param ratio the scale factor to apply to both width and height
  46566. */
  46567. scale(ratio: number): void;
  46568. /**
  46569. * Resizes the texture
  46570. * @param width the new width
  46571. * @param height the new height
  46572. */
  46573. scaleTo(width: number, height: number): void;
  46574. /**
  46575. * Gets the context of the canvas used by the texture
  46576. * @returns the canvas context of the dynamic texture
  46577. */
  46578. getContext(): CanvasRenderingContext2D;
  46579. /**
  46580. * Clears the texture
  46581. */
  46582. clear(): void;
  46583. /**
  46584. * Updates the texture
  46585. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46586. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46587. */
  46588. update(invertY?: boolean, premulAlpha?: boolean): void;
  46589. /**
  46590. * Draws text onto the texture
  46591. * @param text defines the text to be drawn
  46592. * @param x defines the placement of the text from the left
  46593. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46594. * @param font defines the font to be used with font-style, font-size, font-name
  46595. * @param color defines the color used for the text
  46596. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46597. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46598. * @param update defines whether texture is immediately update (default is true)
  46599. */
  46600. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46601. /**
  46602. * Clones the texture
  46603. * @returns the clone of the texture.
  46604. */
  46605. clone(): DynamicTexture;
  46606. /**
  46607. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46608. * @returns a serialized dynamic texture object
  46609. */
  46610. serialize(): any;
  46611. private _IsCanvasElement;
  46612. /** @hidden */
  46613. _rebuild(): void;
  46614. }
  46615. }
  46616. declare module BABYLON {
  46617. /**
  46618. * Class containing static functions to help procedurally build meshes
  46619. */
  46620. export class GroundBuilder {
  46621. /**
  46622. * Creates a ground mesh
  46623. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46624. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46626. * @param name defines the name of the mesh
  46627. * @param options defines the options used to create the mesh
  46628. * @param scene defines the hosting scene
  46629. * @returns the ground mesh
  46630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46631. */
  46632. static CreateGround(name: string, options: {
  46633. width?: number;
  46634. height?: number;
  46635. subdivisions?: number;
  46636. subdivisionsX?: number;
  46637. subdivisionsY?: number;
  46638. updatable?: boolean;
  46639. }, scene: any): Mesh;
  46640. /**
  46641. * Creates a tiled ground mesh
  46642. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46643. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46644. * * 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
  46645. * * 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
  46646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46647. * @param name defines the name of the mesh
  46648. * @param options defines the options used to create the mesh
  46649. * @param scene defines the hosting scene
  46650. * @returns the tiled ground mesh
  46651. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46652. */
  46653. static CreateTiledGround(name: string, options: {
  46654. xmin: number;
  46655. zmin: number;
  46656. xmax: number;
  46657. zmax: number;
  46658. subdivisions?: {
  46659. w: number;
  46660. h: number;
  46661. };
  46662. precision?: {
  46663. w: number;
  46664. h: number;
  46665. };
  46666. updatable?: boolean;
  46667. }, scene?: Nullable<Scene>): Mesh;
  46668. /**
  46669. * Creates a ground mesh from a height map
  46670. * * The parameter `url` sets the URL of the height map image resource.
  46671. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46672. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46673. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46674. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46675. * * 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.
  46676. * * 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).
  46677. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46679. * @param name defines the name of the mesh
  46680. * @param url defines the url to the height map
  46681. * @param options defines the options used to create the mesh
  46682. * @param scene defines the hosting scene
  46683. * @returns the ground mesh
  46684. * @see https://doc.babylonjs.com/babylon101/height_map
  46685. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46686. */
  46687. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46688. width?: number;
  46689. height?: number;
  46690. subdivisions?: number;
  46691. minHeight?: number;
  46692. maxHeight?: number;
  46693. colorFilter?: Color3;
  46694. alphaFilter?: number;
  46695. updatable?: boolean;
  46696. onReady?: (mesh: GroundMesh) => void;
  46697. }, scene?: Nullable<Scene>): GroundMesh;
  46698. }
  46699. }
  46700. declare module BABYLON {
  46701. /**
  46702. * Class containing static functions to help procedurally build meshes
  46703. */
  46704. export class TorusBuilder {
  46705. /**
  46706. * Creates a torus mesh
  46707. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46708. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46709. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46711. * * 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
  46712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46713. * @param name defines the name of the mesh
  46714. * @param options defines the options used to create the mesh
  46715. * @param scene defines the hosting scene
  46716. * @returns the torus mesh
  46717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46718. */
  46719. static CreateTorus(name: string, options: {
  46720. diameter?: number;
  46721. thickness?: number;
  46722. tessellation?: number;
  46723. updatable?: boolean;
  46724. sideOrientation?: number;
  46725. frontUVs?: Vector4;
  46726. backUVs?: Vector4;
  46727. }, scene: any): Mesh;
  46728. }
  46729. }
  46730. declare module BABYLON {
  46731. /**
  46732. * Class containing static functions to help procedurally build meshes
  46733. */
  46734. export class CylinderBuilder {
  46735. /**
  46736. * Creates a cylinder or a cone mesh
  46737. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46738. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46739. * * 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.
  46740. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46741. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46742. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46743. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46744. * * 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).
  46745. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46746. * * 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).
  46747. * * 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
  46748. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46749. * * 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
  46750. * * 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.
  46751. * * If `enclose` is false, a ring surface is one element.
  46752. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46753. * * 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
  46754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46755. * * 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
  46756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46757. * @param name defines the name of the mesh
  46758. * @param options defines the options used to create the mesh
  46759. * @param scene defines the hosting scene
  46760. * @returns the cylinder mesh
  46761. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46762. */
  46763. static CreateCylinder(name: string, options: {
  46764. height?: number;
  46765. diameterTop?: number;
  46766. diameterBottom?: number;
  46767. diameter?: number;
  46768. tessellation?: number;
  46769. subdivisions?: number;
  46770. arc?: number;
  46771. faceColors?: Color4[];
  46772. faceUV?: Vector4[];
  46773. updatable?: boolean;
  46774. hasRings?: boolean;
  46775. enclose?: boolean;
  46776. cap?: number;
  46777. sideOrientation?: number;
  46778. frontUVs?: Vector4;
  46779. backUVs?: Vector4;
  46780. }, scene: any): Mesh;
  46781. }
  46782. }
  46783. declare module BABYLON {
  46784. /**
  46785. * States of the webXR experience
  46786. */
  46787. export enum WebXRState {
  46788. /**
  46789. * Transitioning to being in XR mode
  46790. */
  46791. ENTERING_XR = 0,
  46792. /**
  46793. * Transitioning to non XR mode
  46794. */
  46795. EXITING_XR = 1,
  46796. /**
  46797. * In XR mode and presenting
  46798. */
  46799. IN_XR = 2,
  46800. /**
  46801. * Not entered XR mode
  46802. */
  46803. NOT_IN_XR = 3
  46804. }
  46805. /**
  46806. * Abstraction of the XR render target
  46807. */
  46808. export interface WebXRRenderTarget extends IDisposable {
  46809. /**
  46810. * xrpresent context of the canvas which can be used to display/mirror xr content
  46811. */
  46812. canvasContext: WebGLRenderingContext;
  46813. /**
  46814. * xr layer for the canvas
  46815. */
  46816. xrLayer: Nullable<XRWebGLLayer>;
  46817. /**
  46818. * Initializes the xr layer for the session
  46819. * @param xrSession xr session
  46820. * @returns a promise that will resolve once the XR Layer has been created
  46821. */
  46822. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46823. }
  46824. }
  46825. declare module BABYLON {
  46826. /**
  46827. * COnfiguration object for WebXR output canvas
  46828. */
  46829. export class WebXRManagedOutputCanvasOptions {
  46830. /**
  46831. * An optional canvas in case you wish to create it yourself and provide it here.
  46832. * If not provided, a new canvas will be created
  46833. */
  46834. canvasElement?: HTMLCanvasElement;
  46835. /**
  46836. * Options for this XR Layer output
  46837. */
  46838. canvasOptions?: XRWebGLLayerOptions;
  46839. /**
  46840. * CSS styling for a newly created canvas (if not provided)
  46841. */
  46842. newCanvasCssStyle?: string;
  46843. /**
  46844. * Get the default values of the configuration object
  46845. * @param engine defines the engine to use (can be null)
  46846. * @returns default values of this configuration object
  46847. */
  46848. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46849. }
  46850. /**
  46851. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46852. */
  46853. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46854. private _options;
  46855. private _canvas;
  46856. private _engine;
  46857. private _originalCanvasSize;
  46858. /**
  46859. * Rendering context of the canvas which can be used to display/mirror xr content
  46860. */
  46861. canvasContext: WebGLRenderingContext;
  46862. /**
  46863. * xr layer for the canvas
  46864. */
  46865. xrLayer: Nullable<XRWebGLLayer>;
  46866. /**
  46867. * Obseervers registered here will be triggered when the xr layer was initialized
  46868. */
  46869. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46870. /**
  46871. * Initializes the canvas to be added/removed upon entering/exiting xr
  46872. * @param _xrSessionManager The XR Session manager
  46873. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46874. */
  46875. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46876. /**
  46877. * Disposes of the object
  46878. */
  46879. dispose(): void;
  46880. /**
  46881. * Initializes the xr layer for the session
  46882. * @param xrSession xr session
  46883. * @returns a promise that will resolve once the XR Layer has been created
  46884. */
  46885. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46886. private _addCanvas;
  46887. private _removeCanvas;
  46888. private _setCanvasSize;
  46889. private _setManagedOutputCanvas;
  46890. }
  46891. }
  46892. declare module BABYLON {
  46893. /**
  46894. * Manages an XRSession to work with Babylon's engine
  46895. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46896. */
  46897. export class WebXRSessionManager implements IDisposable {
  46898. /** The scene which the session should be created for */
  46899. scene: Scene;
  46900. private _referenceSpace;
  46901. private _rttProvider;
  46902. private _sessionEnded;
  46903. private _xrNavigator;
  46904. private baseLayer;
  46905. /**
  46906. * The base reference space from which the session started. good if you want to reset your
  46907. * reference space
  46908. */
  46909. baseReferenceSpace: XRReferenceSpace;
  46910. /**
  46911. * Current XR frame
  46912. */
  46913. currentFrame: Nullable<XRFrame>;
  46914. /** WebXR timestamp updated every frame */
  46915. currentTimestamp: number;
  46916. /**
  46917. * Used just in case of a failure to initialize an immersive session.
  46918. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46919. */
  46920. defaultHeightCompensation: number;
  46921. /**
  46922. * Fires every time a new xrFrame arrives which can be used to update the camera
  46923. */
  46924. onXRFrameObservable: Observable<XRFrame>;
  46925. /**
  46926. * Fires when the reference space changed
  46927. */
  46928. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46929. /**
  46930. * Fires when the xr session is ended either by the device or manually done
  46931. */
  46932. onXRSessionEnded: Observable<any>;
  46933. /**
  46934. * Fires when the xr session is ended either by the device or manually done
  46935. */
  46936. onXRSessionInit: Observable<XRSession>;
  46937. /**
  46938. * Underlying xr session
  46939. */
  46940. session: XRSession;
  46941. /**
  46942. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46943. * or get the offset the player is currently at.
  46944. */
  46945. viewerReferenceSpace: XRReferenceSpace;
  46946. /**
  46947. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46948. * @param scene The scene which the session should be created for
  46949. */
  46950. constructor(
  46951. /** The scene which the session should be created for */
  46952. scene: Scene);
  46953. /**
  46954. * The current reference space used in this session. This reference space can constantly change!
  46955. * It is mainly used to offset the camera's position.
  46956. */
  46957. get referenceSpace(): XRReferenceSpace;
  46958. /**
  46959. * Set a new reference space and triggers the observable
  46960. */
  46961. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46962. /**
  46963. * Disposes of the session manager
  46964. */
  46965. dispose(): void;
  46966. /**
  46967. * Stops the xrSession and restores the render loop
  46968. * @returns Promise which resolves after it exits XR
  46969. */
  46970. exitXRAsync(): Promise<void>;
  46971. /**
  46972. * Gets the correct render target texture to be rendered this frame for this eye
  46973. * @param eye the eye for which to get the render target
  46974. * @returns the render target for the specified eye
  46975. */
  46976. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46977. /**
  46978. * Creates a WebXRRenderTarget object for the XR session
  46979. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46980. * @param options optional options to provide when creating a new render target
  46981. * @returns a WebXR render target to which the session can render
  46982. */
  46983. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46984. /**
  46985. * Initializes the manager
  46986. * After initialization enterXR can be called to start an XR session
  46987. * @returns Promise which resolves after it is initialized
  46988. */
  46989. initializeAsync(): Promise<void>;
  46990. /**
  46991. * Initializes an xr session
  46992. * @param xrSessionMode mode to initialize
  46993. * @param xrSessionInit defines optional and required values to pass to the session builder
  46994. * @returns a promise which will resolve once the session has been initialized
  46995. */
  46996. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46997. /**
  46998. * Checks if a session would be supported for the creation options specified
  46999. * @param sessionMode session mode to check if supported eg. immersive-vr
  47000. * @returns A Promise that resolves to true if supported and false if not
  47001. */
  47002. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47003. /**
  47004. * Resets the reference space to the one started the session
  47005. */
  47006. resetReferenceSpace(): void;
  47007. /**
  47008. * Starts rendering to the xr layer
  47009. */
  47010. runXRRenderLoop(): void;
  47011. /**
  47012. * Sets the reference space on the xr session
  47013. * @param referenceSpaceType space to set
  47014. * @returns a promise that will resolve once the reference space has been set
  47015. */
  47016. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47017. /**
  47018. * Updates the render state of the session
  47019. * @param state state to set
  47020. * @returns a promise that resolves once the render state has been updated
  47021. */
  47022. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47023. /**
  47024. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47025. * @param sessionMode defines the session to test
  47026. * @returns a promise with boolean as final value
  47027. */
  47028. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47029. private _createRenderTargetTexture;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /**
  47034. * WebXR Camera which holds the views for the xrSession
  47035. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47036. */
  47037. export class WebXRCamera extends FreeCamera {
  47038. private _xrSessionManager;
  47039. private _firstFrame;
  47040. private _referenceQuaternion;
  47041. private _referencedPosition;
  47042. private _xrInvPositionCache;
  47043. private _xrInvQuaternionCache;
  47044. /**
  47045. * Observable raised before camera teleportation
  47046. */
  47047. onBeforeCameraTeleport: Observable<Vector3>;
  47048. /**
  47049. * Observable raised after camera teleportation
  47050. */
  47051. onAfterCameraTeleport: Observable<Vector3>;
  47052. /**
  47053. * Should position compensation execute on first frame.
  47054. * This is used when copying the position from a native (non XR) camera
  47055. */
  47056. compensateOnFirstFrame: boolean;
  47057. /**
  47058. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47059. * @param name the name of the camera
  47060. * @param scene the scene to add the camera to
  47061. * @param _xrSessionManager a constructed xr session manager
  47062. */
  47063. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47064. /**
  47065. * Return the user's height, unrelated to the current ground.
  47066. * This will be the y position of this camera, when ground level is 0.
  47067. */
  47068. get realWorldHeight(): number;
  47069. /** @hidden */
  47070. _updateForDualEyeDebugging(): void;
  47071. /**
  47072. * Sets this camera's transformation based on a non-vr camera
  47073. * @param otherCamera the non-vr camera to copy the transformation from
  47074. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47075. */
  47076. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47077. /**
  47078. * Gets the current instance class name ("WebXRCamera").
  47079. * @returns the class name
  47080. */
  47081. getClassName(): string;
  47082. private _rotate180;
  47083. private _updateFromXRSession;
  47084. private _updateNumberOfRigCameras;
  47085. private _updateReferenceSpace;
  47086. private _updateReferenceSpaceOffset;
  47087. }
  47088. }
  47089. declare module BABYLON {
  47090. /**
  47091. * Defining the interface required for a (webxr) feature
  47092. */
  47093. export interface IWebXRFeature extends IDisposable {
  47094. /**
  47095. * Is this feature attached
  47096. */
  47097. attached: boolean;
  47098. /**
  47099. * Should auto-attach be disabled?
  47100. */
  47101. disableAutoAttach: boolean;
  47102. /**
  47103. * Attach the feature to the session
  47104. * Will usually be called by the features manager
  47105. *
  47106. * @param force should attachment be forced (even when already attached)
  47107. * @returns true if successful.
  47108. */
  47109. attach(force?: boolean): boolean;
  47110. /**
  47111. * Detach the feature from the session
  47112. * Will usually be called by the features manager
  47113. *
  47114. * @returns true if successful.
  47115. */
  47116. detach(): boolean;
  47117. /**
  47118. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47119. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47120. *
  47121. * @returns whether or not the feature is compatible in this environment
  47122. */
  47123. isCompatible(): boolean;
  47124. /**
  47125. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47126. */
  47127. xrNativeFeatureName?: string;
  47128. /**
  47129. * A list of (Babylon WebXR) features this feature depends on
  47130. */
  47131. dependsOn?: string[];
  47132. }
  47133. /**
  47134. * A list of the currently available features without referencing them
  47135. */
  47136. export class WebXRFeatureName {
  47137. /**
  47138. * The name of the anchor system feature
  47139. */
  47140. static readonly ANCHOR_SYSTEM: string;
  47141. /**
  47142. * The name of the background remover feature
  47143. */
  47144. static readonly BACKGROUND_REMOVER: string;
  47145. /**
  47146. * The name of the hit test feature
  47147. */
  47148. static readonly HIT_TEST: string;
  47149. /**
  47150. * physics impostors for xr controllers feature
  47151. */
  47152. static readonly PHYSICS_CONTROLLERS: string;
  47153. /**
  47154. * The name of the plane detection feature
  47155. */
  47156. static readonly PLANE_DETECTION: string;
  47157. /**
  47158. * The name of the pointer selection feature
  47159. */
  47160. static readonly POINTER_SELECTION: string;
  47161. /**
  47162. * The name of the teleportation feature
  47163. */
  47164. static readonly TELEPORTATION: string;
  47165. /**
  47166. * The name of the feature points feature.
  47167. */
  47168. static readonly FEATURE_POINTS: string;
  47169. /**
  47170. * The name of the hand tracking feature.
  47171. */
  47172. static readonly HAND_TRACKING: string;
  47173. }
  47174. /**
  47175. * Defining the constructor of a feature. Used to register the modules.
  47176. */
  47177. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47178. /**
  47179. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47180. * It is mainly used in AR sessions.
  47181. *
  47182. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47183. */
  47184. export class WebXRFeaturesManager implements IDisposable {
  47185. private _xrSessionManager;
  47186. private static readonly _AvailableFeatures;
  47187. private _features;
  47188. /**
  47189. * constructs a new features manages.
  47190. *
  47191. * @param _xrSessionManager an instance of WebXRSessionManager
  47192. */
  47193. constructor(_xrSessionManager: WebXRSessionManager);
  47194. /**
  47195. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47196. * Mainly used internally.
  47197. *
  47198. * @param featureName the name of the feature to register
  47199. * @param constructorFunction the function used to construct the module
  47200. * @param version the (babylon) version of the module
  47201. * @param stable is that a stable version of this module
  47202. */
  47203. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47204. /**
  47205. * Returns a constructor of a specific feature.
  47206. *
  47207. * @param featureName the name of the feature to construct
  47208. * @param version the version of the feature to load
  47209. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47210. * @param options optional options provided to the module.
  47211. * @returns a function that, when called, will return a new instance of this feature
  47212. */
  47213. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47214. /**
  47215. * Can be used to return the list of features currently registered
  47216. *
  47217. * @returns an Array of available features
  47218. */
  47219. static GetAvailableFeatures(): string[];
  47220. /**
  47221. * Gets the versions available for a specific feature
  47222. * @param featureName the name of the feature
  47223. * @returns an array with the available versions
  47224. */
  47225. static GetAvailableVersions(featureName: string): string[];
  47226. /**
  47227. * Return the latest unstable version of this feature
  47228. * @param featureName the name of the feature to search
  47229. * @returns the version number. if not found will return -1
  47230. */
  47231. static GetLatestVersionOfFeature(featureName: string): number;
  47232. /**
  47233. * Return the latest stable version of this feature
  47234. * @param featureName the name of the feature to search
  47235. * @returns the version number. if not found will return -1
  47236. */
  47237. static GetStableVersionOfFeature(featureName: string): number;
  47238. /**
  47239. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47240. * Can be used during a session to start a feature
  47241. * @param featureName the name of feature to attach
  47242. */
  47243. attachFeature(featureName: string): void;
  47244. /**
  47245. * Can be used inside a session or when the session ends to detach a specific feature
  47246. * @param featureName the name of the feature to detach
  47247. */
  47248. detachFeature(featureName: string): void;
  47249. /**
  47250. * Used to disable an already-enabled feature
  47251. * The feature will be disposed and will be recreated once enabled.
  47252. * @param featureName the feature to disable
  47253. * @returns true if disable was successful
  47254. */
  47255. disableFeature(featureName: string | {
  47256. Name: string;
  47257. }): boolean;
  47258. /**
  47259. * dispose this features manager
  47260. */
  47261. dispose(): void;
  47262. /**
  47263. * 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.
  47264. * 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.
  47265. *
  47266. * @param featureName the name of the feature to load or the class of the feature
  47267. * @param version optional version to load. if not provided the latest version will be enabled
  47268. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47269. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47270. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47271. * @returns a new constructed feature or throws an error if feature not found.
  47272. */
  47273. enableFeature(featureName: string | {
  47274. Name: string;
  47275. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47276. /**
  47277. * get the implementation of an enabled feature.
  47278. * @param featureName the name of the feature to load
  47279. * @returns the feature class, if found
  47280. */
  47281. getEnabledFeature(featureName: string): IWebXRFeature;
  47282. /**
  47283. * Get the list of enabled features
  47284. * @returns an array of enabled features
  47285. */
  47286. getEnabledFeatures(): string[];
  47287. /**
  47288. * This function will exten the session creation configuration object with enabled features.
  47289. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47290. * according to the defined "required" variable, provided during enableFeature call
  47291. * @param xrSessionInit the xr Session init object to extend
  47292. *
  47293. * @returns an extended XRSessionInit object
  47294. */
  47295. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47296. }
  47297. }
  47298. declare module BABYLON {
  47299. /**
  47300. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47301. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47302. */
  47303. export class WebXRExperienceHelper implements IDisposable {
  47304. private scene;
  47305. private _nonVRCamera;
  47306. private _originalSceneAutoClear;
  47307. private _supported;
  47308. /**
  47309. * Camera used to render xr content
  47310. */
  47311. camera: WebXRCamera;
  47312. /** A features manager for this xr session */
  47313. featuresManager: WebXRFeaturesManager;
  47314. /**
  47315. * Observers registered here will be triggered after the camera's initial transformation is set
  47316. * This can be used to set a different ground level or an extra rotation.
  47317. *
  47318. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47319. * to the position set after this observable is done executing.
  47320. */
  47321. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47322. /**
  47323. * Fires when the state of the experience helper has changed
  47324. */
  47325. onStateChangedObservable: Observable<WebXRState>;
  47326. /** Session manager used to keep track of xr session */
  47327. sessionManager: WebXRSessionManager;
  47328. /**
  47329. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47330. */
  47331. state: WebXRState;
  47332. /**
  47333. * Creates a WebXRExperienceHelper
  47334. * @param scene The scene the helper should be created in
  47335. */
  47336. private constructor();
  47337. /**
  47338. * Creates the experience helper
  47339. * @param scene the scene to attach the experience helper to
  47340. * @returns a promise for the experience helper
  47341. */
  47342. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47343. /**
  47344. * Disposes of the experience helper
  47345. */
  47346. dispose(): void;
  47347. /**
  47348. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47349. * @param sessionMode options for the XR session
  47350. * @param referenceSpaceType frame of reference of the XR session
  47351. * @param renderTarget the output canvas that will be used to enter XR mode
  47352. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47353. * @returns promise that resolves after xr mode has entered
  47354. */
  47355. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47356. /**
  47357. * Exits XR mode and returns the scene to its original state
  47358. * @returns promise that resolves after xr mode has exited
  47359. */
  47360. exitXRAsync(): Promise<void>;
  47361. private _nonXRToXRCamera;
  47362. private _setState;
  47363. }
  47364. }
  47365. declare module BABYLON {
  47366. /**
  47367. * X-Y values for axes in WebXR
  47368. */
  47369. export interface IWebXRMotionControllerAxesValue {
  47370. /**
  47371. * The value of the x axis
  47372. */
  47373. x: number;
  47374. /**
  47375. * The value of the y-axis
  47376. */
  47377. y: number;
  47378. }
  47379. /**
  47380. * changed / previous values for the values of this component
  47381. */
  47382. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47383. /**
  47384. * current (this frame) value
  47385. */
  47386. current: T;
  47387. /**
  47388. * previous (last change) value
  47389. */
  47390. previous: T;
  47391. }
  47392. /**
  47393. * Represents changes in the component between current frame and last values recorded
  47394. */
  47395. export interface IWebXRMotionControllerComponentChanges {
  47396. /**
  47397. * will be populated with previous and current values if axes changed
  47398. */
  47399. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47400. /**
  47401. * will be populated with previous and current values if pressed changed
  47402. */
  47403. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47404. /**
  47405. * will be populated with previous and current values if touched changed
  47406. */
  47407. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47408. /**
  47409. * will be populated with previous and current values if value changed
  47410. */
  47411. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47412. }
  47413. /**
  47414. * This class represents a single component (for example button or thumbstick) of a motion controller
  47415. */
  47416. export class WebXRControllerComponent implements IDisposable {
  47417. /**
  47418. * the id of this component
  47419. */
  47420. id: string;
  47421. /**
  47422. * the type of the component
  47423. */
  47424. type: MotionControllerComponentType;
  47425. private _buttonIndex;
  47426. private _axesIndices;
  47427. private _axes;
  47428. private _changes;
  47429. private _currentValue;
  47430. private _hasChanges;
  47431. private _pressed;
  47432. private _touched;
  47433. /**
  47434. * button component type
  47435. */
  47436. static BUTTON_TYPE: MotionControllerComponentType;
  47437. /**
  47438. * squeeze component type
  47439. */
  47440. static SQUEEZE_TYPE: MotionControllerComponentType;
  47441. /**
  47442. * Thumbstick component type
  47443. */
  47444. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47445. /**
  47446. * Touchpad component type
  47447. */
  47448. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47449. /**
  47450. * trigger component type
  47451. */
  47452. static TRIGGER_TYPE: MotionControllerComponentType;
  47453. /**
  47454. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47455. * the axes data changes
  47456. */
  47457. onAxisValueChangedObservable: Observable<{
  47458. x: number;
  47459. y: number;
  47460. }>;
  47461. /**
  47462. * Observers registered here will be triggered when the state of a button changes
  47463. * State change is either pressed / touched / value
  47464. */
  47465. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47466. /**
  47467. * Creates a new component for a motion controller.
  47468. * It is created by the motion controller itself
  47469. *
  47470. * @param id the id of this component
  47471. * @param type the type of the component
  47472. * @param _buttonIndex index in the buttons array of the gamepad
  47473. * @param _axesIndices indices of the values in the axes array of the gamepad
  47474. */
  47475. constructor(
  47476. /**
  47477. * the id of this component
  47478. */
  47479. id: string,
  47480. /**
  47481. * the type of the component
  47482. */
  47483. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47484. /**
  47485. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47486. */
  47487. get axes(): IWebXRMotionControllerAxesValue;
  47488. /**
  47489. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47490. */
  47491. get changes(): IWebXRMotionControllerComponentChanges;
  47492. /**
  47493. * Return whether or not the component changed the last frame
  47494. */
  47495. get hasChanges(): boolean;
  47496. /**
  47497. * is the button currently pressed
  47498. */
  47499. get pressed(): boolean;
  47500. /**
  47501. * is the button currently touched
  47502. */
  47503. get touched(): boolean;
  47504. /**
  47505. * Get the current value of this component
  47506. */
  47507. get value(): number;
  47508. /**
  47509. * Dispose this component
  47510. */
  47511. dispose(): void;
  47512. /**
  47513. * Are there axes correlating to this component
  47514. * @return true is axes data is available
  47515. */
  47516. isAxes(): boolean;
  47517. /**
  47518. * Is this component a button (hence - pressable)
  47519. * @returns true if can be pressed
  47520. */
  47521. isButton(): boolean;
  47522. /**
  47523. * update this component using the gamepad object it is in. Called on every frame
  47524. * @param nativeController the native gamepad controller object
  47525. */
  47526. update(nativeController: IMinimalMotionControllerObject): void;
  47527. }
  47528. }
  47529. declare module BABYLON {
  47530. /**
  47531. * Interface used to represent data loading progression
  47532. */
  47533. export interface ISceneLoaderProgressEvent {
  47534. /**
  47535. * Defines if data length to load can be evaluated
  47536. */
  47537. readonly lengthComputable: boolean;
  47538. /**
  47539. * Defines the loaded data length
  47540. */
  47541. readonly loaded: number;
  47542. /**
  47543. * Defines the data length to load
  47544. */
  47545. readonly total: number;
  47546. }
  47547. /**
  47548. * Interface used by SceneLoader plugins to define supported file extensions
  47549. */
  47550. export interface ISceneLoaderPluginExtensions {
  47551. /**
  47552. * Defines the list of supported extensions
  47553. */
  47554. [extension: string]: {
  47555. isBinary: boolean;
  47556. };
  47557. }
  47558. /**
  47559. * Interface used by SceneLoader plugin factory
  47560. */
  47561. export interface ISceneLoaderPluginFactory {
  47562. /**
  47563. * Defines the name of the factory
  47564. */
  47565. name: string;
  47566. /**
  47567. * Function called to create a new plugin
  47568. * @return the new plugin
  47569. */
  47570. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47571. /**
  47572. * The callback that returns true if the data can be directly loaded.
  47573. * @param data string containing the file data
  47574. * @returns if the data can be loaded directly
  47575. */
  47576. canDirectLoad?(data: string): boolean;
  47577. }
  47578. /**
  47579. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47580. */
  47581. export interface ISceneLoaderPluginBase {
  47582. /**
  47583. * The friendly name of this plugin.
  47584. */
  47585. name: string;
  47586. /**
  47587. * The file extensions supported by this plugin.
  47588. */
  47589. extensions: string | ISceneLoaderPluginExtensions;
  47590. /**
  47591. * The callback called when loading from a url.
  47592. * @param scene scene loading this url
  47593. * @param url url to load
  47594. * @param onSuccess callback called when the file successfully loads
  47595. * @param onProgress callback called while file is loading (if the server supports this mode)
  47596. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47597. * @param onError callback called when the file fails to load
  47598. * @returns a file request object
  47599. */
  47600. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47601. /**
  47602. * The callback called when loading from a file object.
  47603. * @param scene scene loading this file
  47604. * @param file defines the file to load
  47605. * @param onSuccess defines the callback to call when data is loaded
  47606. * @param onProgress defines the callback to call during loading process
  47607. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47608. * @param onError defines the callback to call when an error occurs
  47609. * @returns a file request object
  47610. */
  47611. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47612. /**
  47613. * The callback that returns true if the data can be directly loaded.
  47614. * @param data string containing the file data
  47615. * @returns if the data can be loaded directly
  47616. */
  47617. canDirectLoad?(data: string): boolean;
  47618. /**
  47619. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47620. * @param scene scene loading this data
  47621. * @param data string containing the data
  47622. * @returns data to pass to the plugin
  47623. */
  47624. directLoad?(scene: Scene, data: string): any;
  47625. /**
  47626. * The callback that allows custom handling of the root url based on the response url.
  47627. * @param rootUrl the original root url
  47628. * @param responseURL the response url if available
  47629. * @returns the new root url
  47630. */
  47631. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47632. }
  47633. /**
  47634. * Interface used to define a SceneLoader plugin
  47635. */
  47636. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47637. /**
  47638. * Import meshes into a scene.
  47639. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47640. * @param scene The scene to import into
  47641. * @param data The data to import
  47642. * @param rootUrl The root url for scene and resources
  47643. * @param meshes The meshes array to import into
  47644. * @param particleSystems The particle systems array to import into
  47645. * @param skeletons The skeletons array to import into
  47646. * @param onError The callback when import fails
  47647. * @returns True if successful or false otherwise
  47648. */
  47649. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47650. /**
  47651. * Load into a scene.
  47652. * @param scene The scene to load into
  47653. * @param data The data to import
  47654. * @param rootUrl The root url for scene and resources
  47655. * @param onError The callback when import fails
  47656. * @returns True if successful or false otherwise
  47657. */
  47658. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47659. /**
  47660. * Load into an asset container.
  47661. * @param scene The scene to load into
  47662. * @param data The data to import
  47663. * @param rootUrl The root url for scene and resources
  47664. * @param onError The callback when import fails
  47665. * @returns The loaded asset container
  47666. */
  47667. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47668. }
  47669. /**
  47670. * Interface used to define an async SceneLoader plugin
  47671. */
  47672. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47673. /**
  47674. * Import meshes into a scene.
  47675. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47676. * @param scene The scene to import into
  47677. * @param data The data to import
  47678. * @param rootUrl The root url for scene and resources
  47679. * @param onProgress The callback when the load progresses
  47680. * @param fileName Defines the name of the file to load
  47681. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47682. */
  47683. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47684. meshes: AbstractMesh[];
  47685. particleSystems: IParticleSystem[];
  47686. skeletons: Skeleton[];
  47687. animationGroups: AnimationGroup[];
  47688. }>;
  47689. /**
  47690. * Load into a scene.
  47691. * @param scene The scene to load into
  47692. * @param data The data to import
  47693. * @param rootUrl The root url for scene and resources
  47694. * @param onProgress The callback when the load progresses
  47695. * @param fileName Defines the name of the file to load
  47696. * @returns Nothing
  47697. */
  47698. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47699. /**
  47700. * Load into an asset container.
  47701. * @param scene The scene to load into
  47702. * @param data The data to import
  47703. * @param rootUrl The root url for scene and resources
  47704. * @param onProgress The callback when the load progresses
  47705. * @param fileName Defines the name of the file to load
  47706. * @returns The loaded asset container
  47707. */
  47708. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47709. }
  47710. /**
  47711. * Mode that determines how to handle old animation groups before loading new ones.
  47712. */
  47713. export enum SceneLoaderAnimationGroupLoadingMode {
  47714. /**
  47715. * Reset all old animations to initial state then dispose them.
  47716. */
  47717. Clean = 0,
  47718. /**
  47719. * Stop all old animations.
  47720. */
  47721. Stop = 1,
  47722. /**
  47723. * Restart old animations from first frame.
  47724. */
  47725. Sync = 2,
  47726. /**
  47727. * Old animations remains untouched.
  47728. */
  47729. NoSync = 3
  47730. }
  47731. /**
  47732. * Defines a plugin registered by the SceneLoader
  47733. */
  47734. interface IRegisteredPlugin {
  47735. /**
  47736. * Defines the plugin to use
  47737. */
  47738. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47739. /**
  47740. * Defines if the plugin supports binary data
  47741. */
  47742. isBinary: boolean;
  47743. }
  47744. /**
  47745. * Class used to load scene from various file formats using registered plugins
  47746. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47747. */
  47748. export class SceneLoader {
  47749. /**
  47750. * No logging while loading
  47751. */
  47752. static readonly NO_LOGGING: number;
  47753. /**
  47754. * Minimal logging while loading
  47755. */
  47756. static readonly MINIMAL_LOGGING: number;
  47757. /**
  47758. * Summary logging while loading
  47759. */
  47760. static readonly SUMMARY_LOGGING: number;
  47761. /**
  47762. * Detailled logging while loading
  47763. */
  47764. static readonly DETAILED_LOGGING: number;
  47765. /**
  47766. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47767. */
  47768. static get ForceFullSceneLoadingForIncremental(): boolean;
  47769. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47770. /**
  47771. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47772. */
  47773. static get ShowLoadingScreen(): boolean;
  47774. static set ShowLoadingScreen(value: boolean);
  47775. /**
  47776. * Defines the current logging level (while loading the scene)
  47777. * @ignorenaming
  47778. */
  47779. static get loggingLevel(): number;
  47780. static set loggingLevel(value: number);
  47781. /**
  47782. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47783. */
  47784. static get CleanBoneMatrixWeights(): boolean;
  47785. static set CleanBoneMatrixWeights(value: boolean);
  47786. /**
  47787. * Event raised when a plugin is used to load a scene
  47788. */
  47789. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47790. private static _registeredPlugins;
  47791. private static _showingLoadingScreen;
  47792. /**
  47793. * Gets the default plugin (used to load Babylon files)
  47794. * @returns the .babylon plugin
  47795. */
  47796. static GetDefaultPlugin(): IRegisteredPlugin;
  47797. private static _GetPluginForExtension;
  47798. private static _GetPluginForDirectLoad;
  47799. private static _GetPluginForFilename;
  47800. private static _GetDirectLoad;
  47801. private static _LoadData;
  47802. private static _GetFileInfo;
  47803. /**
  47804. * Gets a plugin that can load the given extension
  47805. * @param extension defines the extension to load
  47806. * @returns a plugin or null if none works
  47807. */
  47808. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47809. /**
  47810. * Gets a boolean indicating that the given extension can be loaded
  47811. * @param extension defines the extension to load
  47812. * @returns true if the extension is supported
  47813. */
  47814. static IsPluginForExtensionAvailable(extension: string): boolean;
  47815. /**
  47816. * Adds a new plugin to the list of registered plugins
  47817. * @param plugin defines the plugin to add
  47818. */
  47819. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47820. /**
  47821. * Import meshes into a scene
  47822. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47823. * @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)
  47824. * @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)
  47825. * @param scene the instance of BABYLON.Scene to append to
  47826. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47827. * @param onProgress a callback with a progress event for each file being loaded
  47828. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47829. * @param pluginExtension the extension used to determine the plugin
  47830. * @returns The loaded plugin
  47831. */
  47832. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47833. /**
  47834. * Import meshes into a scene
  47835. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47836. * @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)
  47837. * @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)
  47838. * @param scene the instance of BABYLON.Scene to append to
  47839. * @param onProgress a callback with a progress event for each file being loaded
  47840. * @param pluginExtension the extension used to determine the plugin
  47841. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47842. */
  47843. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47844. meshes: AbstractMesh[];
  47845. particleSystems: IParticleSystem[];
  47846. skeletons: Skeleton[];
  47847. animationGroups: AnimationGroup[];
  47848. }>;
  47849. /**
  47850. * Load a scene
  47851. * @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)
  47852. * @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)
  47853. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47854. * @param onSuccess a callback with the scene when import succeeds
  47855. * @param onProgress a callback with a progress event for each file being loaded
  47856. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47857. * @param pluginExtension the extension used to determine the plugin
  47858. * @returns The loaded plugin
  47859. */
  47860. 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>;
  47861. /**
  47862. * Load a scene
  47863. * @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)
  47864. * @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)
  47865. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47866. * @param onProgress a callback with a progress event for each file being loaded
  47867. * @param pluginExtension the extension used to determine the plugin
  47868. * @returns The loaded scene
  47869. */
  47870. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47871. /**
  47872. * Append a scene
  47873. * @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)
  47874. * @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)
  47875. * @param scene is the instance of BABYLON.Scene to append to
  47876. * @param onSuccess a callback with the scene when import succeeds
  47877. * @param onProgress a callback with a progress event for each file being loaded
  47878. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47879. * @param pluginExtension the extension used to determine the plugin
  47880. * @returns The loaded plugin
  47881. */
  47882. 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>;
  47883. /**
  47884. * Append a scene
  47885. * @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)
  47886. * @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)
  47887. * @param scene is the instance of BABYLON.Scene to append to
  47888. * @param onProgress a callback with a progress event for each file being loaded
  47889. * @param pluginExtension the extension used to determine the plugin
  47890. * @returns The given scene
  47891. */
  47892. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47893. /**
  47894. * Load a scene into an asset container
  47895. * @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)
  47896. * @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)
  47897. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47898. * @param onSuccess a callback with the scene when import succeeds
  47899. * @param onProgress a callback with a progress event for each file being loaded
  47900. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47901. * @param pluginExtension the extension used to determine the plugin
  47902. * @returns The loaded plugin
  47903. */
  47904. 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>;
  47905. /**
  47906. * Load a scene into an asset container
  47907. * @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)
  47908. * @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)
  47909. * @param scene is the instance of Scene to append to
  47910. * @param onProgress a callback with a progress event for each file being loaded
  47911. * @param pluginExtension the extension used to determine the plugin
  47912. * @returns The loaded asset container
  47913. */
  47914. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47915. /**
  47916. * Import animations from a file into a scene
  47917. * @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)
  47918. * @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)
  47919. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47920. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47921. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47922. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47923. * @param onSuccess a callback with the scene when import succeeds
  47924. * @param onProgress a callback with a progress event for each file being loaded
  47925. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47926. * @param pluginExtension the extension used to determine the plugin
  47927. */
  47928. 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;
  47929. /**
  47930. * Import animations from a file into a scene
  47931. * @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)
  47932. * @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)
  47933. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47934. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47935. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47936. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47937. * @param onSuccess a callback with the scene when import succeeds
  47938. * @param onProgress a callback with a progress event for each file being loaded
  47939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47940. * @param pluginExtension the extension used to determine the plugin
  47941. * @returns the updated scene with imported animations
  47942. */
  47943. 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>;
  47944. }
  47945. }
  47946. declare module BABYLON {
  47947. /**
  47948. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47949. */
  47950. export type MotionControllerHandedness = "none" | "left" | "right";
  47951. /**
  47952. * The type of components available in motion controllers.
  47953. * This is not the name of the component.
  47954. */
  47955. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47956. /**
  47957. * The state of a controller component
  47958. */
  47959. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47960. /**
  47961. * The schema of motion controller layout.
  47962. * No object will be initialized using this interface
  47963. * This is used just to define the profile.
  47964. */
  47965. export interface IMotionControllerLayout {
  47966. /**
  47967. * Path to load the assets. Usually relative to the base path
  47968. */
  47969. assetPath: string;
  47970. /**
  47971. * Available components (unsorted)
  47972. */
  47973. components: {
  47974. /**
  47975. * A map of component Ids
  47976. */
  47977. [componentId: string]: {
  47978. /**
  47979. * The type of input the component outputs
  47980. */
  47981. type: MotionControllerComponentType;
  47982. /**
  47983. * The indices of this component in the gamepad object
  47984. */
  47985. gamepadIndices: {
  47986. /**
  47987. * Index of button
  47988. */
  47989. button?: number;
  47990. /**
  47991. * If available, index of x-axis
  47992. */
  47993. xAxis?: number;
  47994. /**
  47995. * If available, index of y-axis
  47996. */
  47997. yAxis?: number;
  47998. };
  47999. /**
  48000. * The mesh's root node name
  48001. */
  48002. rootNodeName: string;
  48003. /**
  48004. * Animation definitions for this model
  48005. */
  48006. visualResponses: {
  48007. [stateKey: string]: {
  48008. /**
  48009. * What property will be animated
  48010. */
  48011. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48012. /**
  48013. * What states influence this visual response
  48014. */
  48015. states: MotionControllerComponentStateType[];
  48016. /**
  48017. * Type of animation - movement or visibility
  48018. */
  48019. valueNodeProperty: "transform" | "visibility";
  48020. /**
  48021. * Base node name to move. Its position will be calculated according to the min and max nodes
  48022. */
  48023. valueNodeName?: string;
  48024. /**
  48025. * Minimum movement node
  48026. */
  48027. minNodeName?: string;
  48028. /**
  48029. * Max movement node
  48030. */
  48031. maxNodeName?: string;
  48032. };
  48033. };
  48034. /**
  48035. * If touch enabled, what is the name of node to display user feedback
  48036. */
  48037. touchPointNodeName?: string;
  48038. };
  48039. };
  48040. /**
  48041. * Is it xr standard mapping or not
  48042. */
  48043. gamepadMapping: "" | "xr-standard";
  48044. /**
  48045. * Base root node of this entire model
  48046. */
  48047. rootNodeName: string;
  48048. /**
  48049. * Defines the main button component id
  48050. */
  48051. selectComponentId: string;
  48052. }
  48053. /**
  48054. * A definition for the layout map in the input profile
  48055. */
  48056. export interface IMotionControllerLayoutMap {
  48057. /**
  48058. * Layouts with handedness type as a key
  48059. */
  48060. [handedness: string]: IMotionControllerLayout;
  48061. }
  48062. /**
  48063. * The XR Input profile schema
  48064. * Profiles can be found here:
  48065. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48066. */
  48067. export interface IMotionControllerProfile {
  48068. /**
  48069. * fallback profiles for this profileId
  48070. */
  48071. fallbackProfileIds: string[];
  48072. /**
  48073. * The layout map, with handedness as key
  48074. */
  48075. layouts: IMotionControllerLayoutMap;
  48076. /**
  48077. * The id of this profile
  48078. * correlates to the profile(s) in the xrInput.profiles array
  48079. */
  48080. profileId: string;
  48081. }
  48082. /**
  48083. * A helper-interface for the 3 meshes needed for controller button animation
  48084. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48085. */
  48086. export interface IMotionControllerButtonMeshMap {
  48087. /**
  48088. * the mesh that defines the pressed value mesh position.
  48089. * This is used to find the max-position of this button
  48090. */
  48091. pressedMesh: AbstractMesh;
  48092. /**
  48093. * the mesh that defines the unpressed value mesh position.
  48094. * This is used to find the min (or initial) position of this button
  48095. */
  48096. unpressedMesh: AbstractMesh;
  48097. /**
  48098. * The mesh that will be changed when value changes
  48099. */
  48100. valueMesh: AbstractMesh;
  48101. }
  48102. /**
  48103. * A helper-interface for the 3 meshes needed for controller axis animation.
  48104. * This will be expanded when touchpad animations are fully supported
  48105. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48106. */
  48107. export interface IMotionControllerMeshMap {
  48108. /**
  48109. * the mesh that defines the maximum value mesh position.
  48110. */
  48111. maxMesh?: AbstractMesh;
  48112. /**
  48113. * the mesh that defines the minimum value mesh position.
  48114. */
  48115. minMesh?: AbstractMesh;
  48116. /**
  48117. * The mesh that will be changed when axis value changes
  48118. */
  48119. valueMesh?: AbstractMesh;
  48120. }
  48121. /**
  48122. * The elements needed for change-detection of the gamepad objects in motion controllers
  48123. */
  48124. export interface IMinimalMotionControllerObject {
  48125. /**
  48126. * Available axes of this controller
  48127. */
  48128. axes: number[];
  48129. /**
  48130. * An array of available buttons
  48131. */
  48132. buttons: Array<{
  48133. /**
  48134. * Value of the button/trigger
  48135. */
  48136. value: number;
  48137. /**
  48138. * If the button/trigger is currently touched
  48139. */
  48140. touched: boolean;
  48141. /**
  48142. * If the button/trigger is currently pressed
  48143. */
  48144. pressed: boolean;
  48145. }>;
  48146. /**
  48147. * EXPERIMENTAL haptic support.
  48148. */
  48149. hapticActuators?: Array<{
  48150. pulse: (value: number, duration: number) => Promise<boolean>;
  48151. }>;
  48152. }
  48153. /**
  48154. * An Abstract Motion controller
  48155. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48156. * Each component has an observable to check for changes in value and state
  48157. */
  48158. export abstract class WebXRAbstractMotionController implements IDisposable {
  48159. protected scene: Scene;
  48160. protected layout: IMotionControllerLayout;
  48161. /**
  48162. * The gamepad object correlating to this controller
  48163. */
  48164. gamepadObject: IMinimalMotionControllerObject;
  48165. /**
  48166. * handedness (left/right/none) of this controller
  48167. */
  48168. handedness: MotionControllerHandedness;
  48169. private _initComponent;
  48170. private _modelReady;
  48171. /**
  48172. * A map of components (WebXRControllerComponent) in this motion controller
  48173. * Components have a ComponentType and can also have both button and axis definitions
  48174. */
  48175. readonly components: {
  48176. [id: string]: WebXRControllerComponent;
  48177. };
  48178. /**
  48179. * Disable the model's animation. Can be set at any time.
  48180. */
  48181. disableAnimation: boolean;
  48182. /**
  48183. * Observers registered here will be triggered when the model of this controller is done loading
  48184. */
  48185. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48186. /**
  48187. * The profile id of this motion controller
  48188. */
  48189. abstract profileId: string;
  48190. /**
  48191. * The root mesh of the model. It is null if the model was not yet initialized
  48192. */
  48193. rootMesh: Nullable<AbstractMesh>;
  48194. /**
  48195. * constructs a new abstract motion controller
  48196. * @param scene the scene to which the model of the controller will be added
  48197. * @param layout The profile layout to load
  48198. * @param gamepadObject The gamepad object correlating to this controller
  48199. * @param handedness handedness (left/right/none) of this controller
  48200. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48201. */
  48202. constructor(scene: Scene, layout: IMotionControllerLayout,
  48203. /**
  48204. * The gamepad object correlating to this controller
  48205. */
  48206. gamepadObject: IMinimalMotionControllerObject,
  48207. /**
  48208. * handedness (left/right/none) of this controller
  48209. */
  48210. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48211. /**
  48212. * Dispose this controller, the model mesh and all its components
  48213. */
  48214. dispose(): void;
  48215. /**
  48216. * Returns all components of specific type
  48217. * @param type the type to search for
  48218. * @return an array of components with this type
  48219. */
  48220. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48221. /**
  48222. * get a component based an its component id as defined in layout.components
  48223. * @param id the id of the component
  48224. * @returns the component correlates to the id or undefined if not found
  48225. */
  48226. getComponent(id: string): WebXRControllerComponent;
  48227. /**
  48228. * Get the list of components available in this motion controller
  48229. * @returns an array of strings correlating to available components
  48230. */
  48231. getComponentIds(): string[];
  48232. /**
  48233. * Get the first component of specific type
  48234. * @param type type of component to find
  48235. * @return a controller component or null if not found
  48236. */
  48237. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48238. /**
  48239. * Get the main (Select) component of this controller as defined in the layout
  48240. * @returns the main component of this controller
  48241. */
  48242. getMainComponent(): WebXRControllerComponent;
  48243. /**
  48244. * Loads the model correlating to this controller
  48245. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48246. * @returns A promise fulfilled with the result of the model loading
  48247. */
  48248. loadModel(): Promise<boolean>;
  48249. /**
  48250. * Update this model using the current XRFrame
  48251. * @param xrFrame the current xr frame to use and update the model
  48252. */
  48253. updateFromXRFrame(xrFrame: XRFrame): void;
  48254. /**
  48255. * Backwards compatibility due to a deeply-integrated typo
  48256. */
  48257. get handness(): XREye;
  48258. /**
  48259. * Pulse (vibrate) this controller
  48260. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48261. * Consecutive calls to this function will cancel the last pulse call
  48262. *
  48263. * @param value the strength of the pulse in 0.0...1.0 range
  48264. * @param duration Duration of the pulse in milliseconds
  48265. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48266. * @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
  48267. */
  48268. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48269. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48270. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48271. /**
  48272. * Moves the axis on the controller mesh based on its current state
  48273. * @param axis the index of the axis
  48274. * @param axisValue the value of the axis which determines the meshes new position
  48275. * @hidden
  48276. */
  48277. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48278. /**
  48279. * Update the model itself with the current frame data
  48280. * @param xrFrame the frame to use for updating the model mesh
  48281. */
  48282. protected updateModel(xrFrame: XRFrame): void;
  48283. /**
  48284. * Get the filename and path for this controller's model
  48285. * @returns a map of filename and path
  48286. */
  48287. protected abstract _getFilenameAndPath(): {
  48288. filename: string;
  48289. path: string;
  48290. };
  48291. /**
  48292. * This function is called before the mesh is loaded. It checks for loading constraints.
  48293. * For example, this function can check if the GLB loader is available
  48294. * If this function returns false, the generic controller will be loaded instead
  48295. * @returns Is the client ready to load the mesh
  48296. */
  48297. protected abstract _getModelLoadingConstraints(): boolean;
  48298. /**
  48299. * This function will be called after the model was successfully loaded and can be used
  48300. * for mesh transformations before it is available for the user
  48301. * @param meshes the loaded meshes
  48302. */
  48303. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48304. /**
  48305. * Set the root mesh for this controller. Important for the WebXR controller class
  48306. * @param meshes the loaded meshes
  48307. */
  48308. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48309. /**
  48310. * A function executed each frame that updates the mesh (if needed)
  48311. * @param xrFrame the current xrFrame
  48312. */
  48313. protected abstract _updateModel(xrFrame: XRFrame): void;
  48314. private _getGenericFilenameAndPath;
  48315. private _getGenericParentMesh;
  48316. }
  48317. }
  48318. declare module BABYLON {
  48319. /**
  48320. * A generic trigger-only motion controller for WebXR
  48321. */
  48322. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48323. /**
  48324. * Static version of the profile id of this controller
  48325. */
  48326. static ProfileId: string;
  48327. profileId: string;
  48328. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48329. protected _getFilenameAndPath(): {
  48330. filename: string;
  48331. path: string;
  48332. };
  48333. protected _getModelLoadingConstraints(): boolean;
  48334. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48335. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48336. protected _updateModel(): void;
  48337. }
  48338. }
  48339. declare module BABYLON {
  48340. /**
  48341. * Class containing static functions to help procedurally build meshes
  48342. */
  48343. export class SphereBuilder {
  48344. /**
  48345. * Creates a sphere mesh
  48346. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48347. * * 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`)
  48348. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48349. * * 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
  48350. * * 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)
  48351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48352. * * 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
  48353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48354. * @param name defines the name of the mesh
  48355. * @param options defines the options used to create the mesh
  48356. * @param scene defines the hosting scene
  48357. * @returns the sphere mesh
  48358. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48359. */
  48360. static CreateSphere(name: string, options: {
  48361. segments?: number;
  48362. diameter?: number;
  48363. diameterX?: number;
  48364. diameterY?: number;
  48365. diameterZ?: number;
  48366. arc?: number;
  48367. slice?: number;
  48368. sideOrientation?: number;
  48369. frontUVs?: Vector4;
  48370. backUVs?: Vector4;
  48371. updatable?: boolean;
  48372. }, scene?: Nullable<Scene>): Mesh;
  48373. }
  48374. }
  48375. declare module BABYLON {
  48376. /**
  48377. * A profiled motion controller has its profile loaded from an online repository.
  48378. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48379. */
  48380. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48381. private _repositoryUrl;
  48382. private _buttonMeshMapping;
  48383. private _touchDots;
  48384. /**
  48385. * The profile ID of this controller. Will be populated when the controller initializes.
  48386. */
  48387. profileId: string;
  48388. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48389. dispose(): void;
  48390. protected _getFilenameAndPath(): {
  48391. filename: string;
  48392. path: string;
  48393. };
  48394. protected _getModelLoadingConstraints(): boolean;
  48395. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48396. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48397. protected _updateModel(_xrFrame: XRFrame): void;
  48398. }
  48399. }
  48400. declare module BABYLON {
  48401. /**
  48402. * A construction function type to create a new controller based on an xrInput object
  48403. */
  48404. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48405. /**
  48406. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48407. *
  48408. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48409. * it should be replaced with auto-loaded controllers.
  48410. *
  48411. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48412. */
  48413. export class WebXRMotionControllerManager {
  48414. private static _AvailableControllers;
  48415. private static _Fallbacks;
  48416. private static _ProfileLoadingPromises;
  48417. private static _ProfilesList;
  48418. /**
  48419. * The base URL of the online controller repository. Can be changed at any time.
  48420. */
  48421. static BaseRepositoryUrl: string;
  48422. /**
  48423. * Which repository gets priority - local or online
  48424. */
  48425. static PrioritizeOnlineRepository: boolean;
  48426. /**
  48427. * Use the online repository, or use only locally-defined controllers
  48428. */
  48429. static UseOnlineRepository: boolean;
  48430. /**
  48431. * Clear the cache used for profile loading and reload when requested again
  48432. */
  48433. static ClearProfilesCache(): void;
  48434. /**
  48435. * Register the default fallbacks.
  48436. * This function is called automatically when this file is imported.
  48437. */
  48438. static DefaultFallbacks(): void;
  48439. /**
  48440. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48441. * @param profileId the profile to which a fallback needs to be found
  48442. * @return an array with corresponding fallback profiles
  48443. */
  48444. static FindFallbackWithProfileId(profileId: string): string[];
  48445. /**
  48446. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48447. * The order of search:
  48448. *
  48449. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48450. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48451. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48452. * 4) return the generic trigger controller if none were found
  48453. *
  48454. * @param xrInput the xrInput to which a new controller is initialized
  48455. * @param scene the scene to which the model will be added
  48456. * @param forceProfile force a certain profile for this controller
  48457. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48458. */
  48459. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48460. /**
  48461. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48462. *
  48463. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48464. *
  48465. * @param type the profile type to register
  48466. * @param constructFunction the function to be called when loading this profile
  48467. */
  48468. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48469. /**
  48470. * Register a fallback to a specific profile.
  48471. * @param profileId the profileId that will receive the fallbacks
  48472. * @param fallbacks A list of fallback profiles
  48473. */
  48474. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48475. /**
  48476. * Will update the list of profiles available in the repository
  48477. * @return a promise that resolves to a map of profiles available online
  48478. */
  48479. static UpdateProfilesList(): Promise<{
  48480. [profile: string]: string;
  48481. }>;
  48482. private static _LoadProfileFromRepository;
  48483. private static _LoadProfilesFromAvailableControllers;
  48484. }
  48485. }
  48486. declare module BABYLON {
  48487. /**
  48488. * Configuration options for the WebXR controller creation
  48489. */
  48490. export interface IWebXRControllerOptions {
  48491. /**
  48492. * Should the controller mesh be animated when a user interacts with it
  48493. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48494. */
  48495. disableMotionControllerAnimation?: boolean;
  48496. /**
  48497. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48498. */
  48499. doNotLoadControllerMesh?: boolean;
  48500. /**
  48501. * Force a specific controller type for this controller.
  48502. * This can be used when creating your own profile or when testing different controllers
  48503. */
  48504. forceControllerProfile?: string;
  48505. /**
  48506. * Defines a rendering group ID for meshes that will be loaded.
  48507. * This is for the default controllers only.
  48508. */
  48509. renderingGroupId?: number;
  48510. }
  48511. /**
  48512. * Represents an XR controller
  48513. */
  48514. export class WebXRInputSource {
  48515. private _scene;
  48516. /** The underlying input source for the controller */
  48517. inputSource: XRInputSource;
  48518. private _options;
  48519. private _tmpVector;
  48520. private _uniqueId;
  48521. private _disposed;
  48522. /**
  48523. * 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
  48524. */
  48525. grip?: AbstractMesh;
  48526. /**
  48527. * If available, this is the gamepad object related to this controller.
  48528. * Using this object it is possible to get click events and trackpad changes of the
  48529. * webxr controller that is currently being used.
  48530. */
  48531. motionController?: WebXRAbstractMotionController;
  48532. /**
  48533. * Event that fires when the controller is removed/disposed.
  48534. * The object provided as event data is this controller, after associated assets were disposed.
  48535. * uniqueId is still available.
  48536. */
  48537. onDisposeObservable: Observable<WebXRInputSource>;
  48538. /**
  48539. * Will be triggered when the mesh associated with the motion controller is done loading.
  48540. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48541. * A shortened version of controller -> motion controller -> on mesh loaded.
  48542. */
  48543. onMeshLoadedObservable: Observable<AbstractMesh>;
  48544. /**
  48545. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48546. */
  48547. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48548. /**
  48549. * Pointer which can be used to select objects or attach a visible laser to
  48550. */
  48551. pointer: AbstractMesh;
  48552. /**
  48553. * Creates the input source object
  48554. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48555. * @param _scene the scene which the controller should be associated to
  48556. * @param inputSource the underlying input source for the controller
  48557. * @param _options options for this controller creation
  48558. */
  48559. constructor(_scene: Scene,
  48560. /** The underlying input source for the controller */
  48561. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48562. /**
  48563. * Get this controllers unique id
  48564. */
  48565. get uniqueId(): string;
  48566. /**
  48567. * Disposes of the object
  48568. */
  48569. dispose(): void;
  48570. /**
  48571. * Gets a world space ray coming from the pointer or grip
  48572. * @param result the resulting ray
  48573. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48574. */
  48575. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48576. /**
  48577. * Updates the controller pose based on the given XRFrame
  48578. * @param xrFrame xr frame to update the pose with
  48579. * @param referenceSpace reference space to use
  48580. */
  48581. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48582. }
  48583. }
  48584. declare module BABYLON {
  48585. /**
  48586. * The schema for initialization options of the XR Input class
  48587. */
  48588. export interface IWebXRInputOptions {
  48589. /**
  48590. * If set to true no model will be automatically loaded
  48591. */
  48592. doNotLoadControllerMeshes?: boolean;
  48593. /**
  48594. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48595. * If not found, the xr input profile data will be used.
  48596. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48597. */
  48598. forceInputProfile?: string;
  48599. /**
  48600. * Do not send a request to the controller repository to load the profile.
  48601. *
  48602. * Instead, use the controllers available in babylon itself.
  48603. */
  48604. disableOnlineControllerRepository?: boolean;
  48605. /**
  48606. * A custom URL for the controllers repository
  48607. */
  48608. customControllersRepositoryURL?: string;
  48609. /**
  48610. * Should the controller model's components not move according to the user input
  48611. */
  48612. disableControllerAnimation?: boolean;
  48613. /**
  48614. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48615. */
  48616. controllerOptions?: IWebXRControllerOptions;
  48617. }
  48618. /**
  48619. * XR input used to track XR inputs such as controllers/rays
  48620. */
  48621. export class WebXRInput implements IDisposable {
  48622. /**
  48623. * the xr session manager for this session
  48624. */
  48625. xrSessionManager: WebXRSessionManager;
  48626. /**
  48627. * the WebXR camera for this session. Mainly used for teleportation
  48628. */
  48629. xrCamera: WebXRCamera;
  48630. private readonly options;
  48631. /**
  48632. * XR controllers being tracked
  48633. */
  48634. controllers: Array<WebXRInputSource>;
  48635. private _frameObserver;
  48636. private _sessionEndedObserver;
  48637. private _sessionInitObserver;
  48638. /**
  48639. * Event when a controller has been connected/added
  48640. */
  48641. onControllerAddedObservable: Observable<WebXRInputSource>;
  48642. /**
  48643. * Event when a controller has been removed/disconnected
  48644. */
  48645. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48646. /**
  48647. * Initializes the WebXRInput
  48648. * @param xrSessionManager the xr session manager for this session
  48649. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48650. * @param options = initialization options for this xr input
  48651. */
  48652. constructor(
  48653. /**
  48654. * the xr session manager for this session
  48655. */
  48656. xrSessionManager: WebXRSessionManager,
  48657. /**
  48658. * the WebXR camera for this session. Mainly used for teleportation
  48659. */
  48660. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48661. private _onInputSourcesChange;
  48662. private _addAndRemoveControllers;
  48663. /**
  48664. * Disposes of the object
  48665. */
  48666. dispose(): void;
  48667. }
  48668. }
  48669. declare module BABYLON {
  48670. /**
  48671. * This is the base class for all WebXR features.
  48672. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48673. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48674. */
  48675. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48676. protected _xrSessionManager: WebXRSessionManager;
  48677. private _attached;
  48678. private _removeOnDetach;
  48679. /**
  48680. * Should auto-attach be disabled?
  48681. */
  48682. disableAutoAttach: boolean;
  48683. /**
  48684. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48685. */
  48686. xrNativeFeatureName: string;
  48687. /**
  48688. * Construct a new (abstract) WebXR feature
  48689. * @param _xrSessionManager the xr session manager for this feature
  48690. */
  48691. constructor(_xrSessionManager: WebXRSessionManager);
  48692. /**
  48693. * Is this feature attached
  48694. */
  48695. get attached(): boolean;
  48696. /**
  48697. * attach this feature
  48698. *
  48699. * @param force should attachment be forced (even when already attached)
  48700. * @returns true if successful, false is failed or already attached
  48701. */
  48702. attach(force?: boolean): boolean;
  48703. /**
  48704. * detach this feature.
  48705. *
  48706. * @returns true if successful, false if failed or already detached
  48707. */
  48708. detach(): boolean;
  48709. /**
  48710. * Dispose this feature and all of the resources attached
  48711. */
  48712. dispose(): void;
  48713. /**
  48714. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48715. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48716. *
  48717. * @returns whether or not the feature is compatible in this environment
  48718. */
  48719. isCompatible(): boolean;
  48720. /**
  48721. * This is used to register callbacks that will automatically be removed when detach is called.
  48722. * @param observable the observable to which the observer will be attached
  48723. * @param callback the callback to register
  48724. */
  48725. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48726. /**
  48727. * Code in this function will be executed on each xrFrame received from the browser.
  48728. * This function will not execute after the feature is detached.
  48729. * @param _xrFrame the current frame
  48730. */
  48731. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48732. }
  48733. }
  48734. declare module BABYLON {
  48735. /**
  48736. * Renders a layer on top of an existing scene
  48737. */
  48738. export class UtilityLayerRenderer implements IDisposable {
  48739. /** the original scene that will be rendered on top of */
  48740. originalScene: Scene;
  48741. private _pointerCaptures;
  48742. private _lastPointerEvents;
  48743. private static _DefaultUtilityLayer;
  48744. private static _DefaultKeepDepthUtilityLayer;
  48745. private _sharedGizmoLight;
  48746. private _renderCamera;
  48747. /**
  48748. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48749. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48750. * @returns the camera that is used when rendering the utility layer
  48751. */
  48752. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48753. /**
  48754. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48755. * @param cam the camera that should be used when rendering the utility layer
  48756. */
  48757. setRenderCamera(cam: Nullable<Camera>): void;
  48758. /**
  48759. * @hidden
  48760. * Light which used by gizmos to get light shading
  48761. */
  48762. _getSharedGizmoLight(): HemisphericLight;
  48763. /**
  48764. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48765. */
  48766. pickUtilitySceneFirst: boolean;
  48767. /**
  48768. * 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)
  48769. */
  48770. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48771. /**
  48772. * 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)
  48773. */
  48774. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48775. /**
  48776. * The scene that is rendered on top of the original scene
  48777. */
  48778. utilityLayerScene: Scene;
  48779. /**
  48780. * If the utility layer should automatically be rendered on top of existing scene
  48781. */
  48782. shouldRender: boolean;
  48783. /**
  48784. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48785. */
  48786. onlyCheckPointerDownEvents: boolean;
  48787. /**
  48788. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48789. */
  48790. processAllEvents: boolean;
  48791. /**
  48792. * Observable raised when the pointer move from the utility layer scene to the main scene
  48793. */
  48794. onPointerOutObservable: Observable<number>;
  48795. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48796. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48797. private _afterRenderObserver;
  48798. private _sceneDisposeObserver;
  48799. private _originalPointerObserver;
  48800. /**
  48801. * Instantiates a UtilityLayerRenderer
  48802. * @param originalScene the original scene that will be rendered on top of
  48803. * @param handleEvents boolean indicating if the utility layer should handle events
  48804. */
  48805. constructor(
  48806. /** the original scene that will be rendered on top of */
  48807. originalScene: Scene, handleEvents?: boolean);
  48808. private _notifyObservers;
  48809. /**
  48810. * Renders the utility layers scene on top of the original scene
  48811. */
  48812. render(): void;
  48813. /**
  48814. * Disposes of the renderer
  48815. */
  48816. dispose(): void;
  48817. private _updateCamera;
  48818. }
  48819. }
  48820. declare module BABYLON {
  48821. /**
  48822. * Options interface for the pointer selection module
  48823. */
  48824. export interface IWebXRControllerPointerSelectionOptions {
  48825. /**
  48826. * if provided, this scene will be used to render meshes.
  48827. */
  48828. customUtilityLayerScene?: Scene;
  48829. /**
  48830. * 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)
  48831. * If not disabled, the last picked point will be used to execute a pointer up event
  48832. * If disabled, pointer up event will be triggered right after the pointer down event.
  48833. * Used in screen and gaze target ray mode only
  48834. */
  48835. disablePointerUpOnTouchOut: boolean;
  48836. /**
  48837. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48838. */
  48839. forceGazeMode: boolean;
  48840. /**
  48841. * 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
  48842. * to start a new countdown to the pointer down event.
  48843. * Defaults to 1.
  48844. */
  48845. gazeModePointerMovedFactor?: number;
  48846. /**
  48847. * Different button type to use instead of the main component
  48848. */
  48849. overrideButtonId?: string;
  48850. /**
  48851. * use this rendering group id for the meshes (optional)
  48852. */
  48853. renderingGroupId?: number;
  48854. /**
  48855. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48856. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48857. * 3000 means 3 seconds between pointing at something and selecting it
  48858. */
  48859. timeToSelect?: number;
  48860. /**
  48861. * Should meshes created here be added to a utility layer or the main scene
  48862. */
  48863. useUtilityLayer?: boolean;
  48864. /**
  48865. * Optional WebXR camera to be used for gaze selection
  48866. */
  48867. gazeCamera?: WebXRCamera;
  48868. /**
  48869. * the xr input to use with this pointer selection
  48870. */
  48871. xrInput: WebXRInput;
  48872. }
  48873. /**
  48874. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48875. */
  48876. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48877. private readonly _options;
  48878. private static _idCounter;
  48879. private _attachController;
  48880. private _controllers;
  48881. private _scene;
  48882. private _tmpVectorForPickCompare;
  48883. /**
  48884. * The module's name
  48885. */
  48886. static readonly Name: string;
  48887. /**
  48888. * The (Babylon) version of this module.
  48889. * This is an integer representing the implementation version.
  48890. * This number does not correspond to the WebXR specs version
  48891. */
  48892. static readonly Version: number;
  48893. /**
  48894. * Disable lighting on the laser pointer (so it will always be visible)
  48895. */
  48896. disablePointerLighting: boolean;
  48897. /**
  48898. * Disable lighting on the selection mesh (so it will always be visible)
  48899. */
  48900. disableSelectionMeshLighting: boolean;
  48901. /**
  48902. * Should the laser pointer be displayed
  48903. */
  48904. displayLaserPointer: boolean;
  48905. /**
  48906. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48907. */
  48908. displaySelectionMesh: boolean;
  48909. /**
  48910. * This color will be set to the laser pointer when selection is triggered
  48911. */
  48912. laserPointerPickedColor: Color3;
  48913. /**
  48914. * Default color of the laser pointer
  48915. */
  48916. laserPointerDefaultColor: Color3;
  48917. /**
  48918. * default color of the selection ring
  48919. */
  48920. selectionMeshDefaultColor: Color3;
  48921. /**
  48922. * This color will be applied to the selection ring when selection is triggered
  48923. */
  48924. selectionMeshPickedColor: Color3;
  48925. /**
  48926. * Optional filter to be used for ray selection. This predicate shares behavior with
  48927. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48928. */
  48929. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48930. /**
  48931. * constructs a new background remover module
  48932. * @param _xrSessionManager the session manager for this module
  48933. * @param _options read-only options to be used in this module
  48934. */
  48935. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48936. /**
  48937. * attach this feature
  48938. * Will usually be called by the features manager
  48939. *
  48940. * @returns true if successful.
  48941. */
  48942. attach(): boolean;
  48943. /**
  48944. * detach this feature.
  48945. * Will usually be called by the features manager
  48946. *
  48947. * @returns true if successful.
  48948. */
  48949. detach(): boolean;
  48950. /**
  48951. * Will get the mesh under a specific pointer.
  48952. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48953. * @param controllerId the controllerId to check
  48954. * @returns The mesh under pointer or null if no mesh is under the pointer
  48955. */
  48956. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48957. /**
  48958. * Get the xr controller that correlates to the pointer id in the pointer event
  48959. *
  48960. * @param id the pointer id to search for
  48961. * @returns the controller that correlates to this id or null if not found
  48962. */
  48963. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48964. protected _onXRFrame(_xrFrame: XRFrame): void;
  48965. private _attachGazeMode;
  48966. private _attachScreenRayMode;
  48967. private _attachTrackedPointerRayMode;
  48968. private _convertNormalToDirectionOfRay;
  48969. private _detachController;
  48970. private _generateNewMeshPair;
  48971. private _pickingMoved;
  48972. private _updatePointerDistance;
  48973. /** @hidden */
  48974. get lasterPointerDefaultColor(): Color3;
  48975. }
  48976. }
  48977. declare module BABYLON {
  48978. /**
  48979. * Button which can be used to enter a different mode of XR
  48980. */
  48981. export class WebXREnterExitUIButton {
  48982. /** button element */
  48983. element: HTMLElement;
  48984. /** XR initialization options for the button */
  48985. sessionMode: XRSessionMode;
  48986. /** Reference space type */
  48987. referenceSpaceType: XRReferenceSpaceType;
  48988. /**
  48989. * Creates a WebXREnterExitUIButton
  48990. * @param element button element
  48991. * @param sessionMode XR initialization session mode
  48992. * @param referenceSpaceType the type of reference space to be used
  48993. */
  48994. constructor(
  48995. /** button element */
  48996. element: HTMLElement,
  48997. /** XR initialization options for the button */
  48998. sessionMode: XRSessionMode,
  48999. /** Reference space type */
  49000. referenceSpaceType: XRReferenceSpaceType);
  49001. /**
  49002. * Extendable function which can be used to update the button's visuals when the state changes
  49003. * @param activeButton the current active button in the UI
  49004. */
  49005. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49006. }
  49007. /**
  49008. * Options to create the webXR UI
  49009. */
  49010. export class WebXREnterExitUIOptions {
  49011. /**
  49012. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49013. */
  49014. customButtons?: Array<WebXREnterExitUIButton>;
  49015. /**
  49016. * A reference space type to use when creating the default button.
  49017. * Default is local-floor
  49018. */
  49019. referenceSpaceType?: XRReferenceSpaceType;
  49020. /**
  49021. * Context to enter xr with
  49022. */
  49023. renderTarget?: Nullable<WebXRRenderTarget>;
  49024. /**
  49025. * A session mode to use when creating the default button.
  49026. * Default is immersive-vr
  49027. */
  49028. sessionMode?: XRSessionMode;
  49029. /**
  49030. * A list of optional features to init the session with
  49031. */
  49032. optionalFeatures?: string[];
  49033. /**
  49034. * A list of optional features to init the session with
  49035. */
  49036. requiredFeatures?: string[];
  49037. }
  49038. /**
  49039. * UI to allow the user to enter/exit XR mode
  49040. */
  49041. export class WebXREnterExitUI implements IDisposable {
  49042. private scene;
  49043. /** version of the options passed to this UI */
  49044. options: WebXREnterExitUIOptions;
  49045. private _activeButton;
  49046. private _buttons;
  49047. /**
  49048. * The HTML Div Element to which buttons are added.
  49049. */
  49050. readonly overlay: HTMLDivElement;
  49051. /**
  49052. * Fired every time the active button is changed.
  49053. *
  49054. * When xr is entered via a button that launches xr that button will be the callback parameter
  49055. *
  49056. * When exiting xr the callback parameter will be null)
  49057. */
  49058. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49059. /**
  49060. *
  49061. * @param scene babylon scene object to use
  49062. * @param options (read-only) version of the options passed to this UI
  49063. */
  49064. private constructor();
  49065. /**
  49066. * Creates UI to allow the user to enter/exit XR mode
  49067. * @param scene the scene to add the ui to
  49068. * @param helper the xr experience helper to enter/exit xr with
  49069. * @param options options to configure the UI
  49070. * @returns the created ui
  49071. */
  49072. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49073. /**
  49074. * Disposes of the XR UI component
  49075. */
  49076. dispose(): void;
  49077. private _updateButtons;
  49078. }
  49079. }
  49080. declare module BABYLON {
  49081. /**
  49082. * Class containing static functions to help procedurally build meshes
  49083. */
  49084. export class LinesBuilder {
  49085. /**
  49086. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49087. * * 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
  49088. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49089. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49090. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49091. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49092. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49093. * * 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
  49094. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49097. * @param name defines the name of the new line system
  49098. * @param options defines the options used to create the line system
  49099. * @param scene defines the hosting scene
  49100. * @returns a new line system mesh
  49101. */
  49102. static CreateLineSystem(name: string, options: {
  49103. lines: Vector3[][];
  49104. updatable?: boolean;
  49105. instance?: Nullable<LinesMesh>;
  49106. colors?: Nullable<Color4[][]>;
  49107. useVertexAlpha?: boolean;
  49108. }, scene: Nullable<Scene>): LinesMesh;
  49109. /**
  49110. * Creates a line mesh
  49111. * 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
  49112. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49113. * * The parameter `points` is an array successive Vector3
  49114. * * 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
  49115. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49116. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49117. * * When updating an instance, remember that only point positions can change, not the number of points
  49118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49120. * @param name defines the name of the new line system
  49121. * @param options defines the options used to create the line system
  49122. * @param scene defines the hosting scene
  49123. * @returns a new line mesh
  49124. */
  49125. static CreateLines(name: string, options: {
  49126. points: Vector3[];
  49127. updatable?: boolean;
  49128. instance?: Nullable<LinesMesh>;
  49129. colors?: Color4[];
  49130. useVertexAlpha?: boolean;
  49131. }, scene?: Nullable<Scene>): LinesMesh;
  49132. /**
  49133. * Creates a dashed line mesh
  49134. * * 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
  49135. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49136. * * The parameter `points` is an array successive Vector3
  49137. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49138. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49139. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49140. * * 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
  49141. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49142. * * When updating an instance, remember that only point positions can change, not the number of points
  49143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49144. * @param name defines the name of the mesh
  49145. * @param options defines the options used to create the mesh
  49146. * @param scene defines the hosting scene
  49147. * @returns the dashed line mesh
  49148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49149. */
  49150. static CreateDashedLines(name: string, options: {
  49151. points: Vector3[];
  49152. dashSize?: number;
  49153. gapSize?: number;
  49154. dashNb?: number;
  49155. updatable?: boolean;
  49156. instance?: LinesMesh;
  49157. useVertexAlpha?: boolean;
  49158. }, scene?: Nullable<Scene>): LinesMesh;
  49159. }
  49160. }
  49161. declare module BABYLON {
  49162. /**
  49163. * Construction options for a timer
  49164. */
  49165. export interface ITimerOptions<T> {
  49166. /**
  49167. * Time-to-end
  49168. */
  49169. timeout: number;
  49170. /**
  49171. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49172. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49173. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49174. */
  49175. contextObservable: Observable<T>;
  49176. /**
  49177. * Optional parameters when adding an observer to the observable
  49178. */
  49179. observableParameters?: {
  49180. mask?: number;
  49181. insertFirst?: boolean;
  49182. scope?: any;
  49183. };
  49184. /**
  49185. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49186. */
  49187. breakCondition?: (data?: ITimerData<T>) => boolean;
  49188. /**
  49189. * Will be triggered when the time condition has met
  49190. */
  49191. onEnded?: (data: ITimerData<any>) => void;
  49192. /**
  49193. * Will be triggered when the break condition has met (prematurely ended)
  49194. */
  49195. onAborted?: (data: ITimerData<any>) => void;
  49196. /**
  49197. * Optional function to execute on each tick (or count)
  49198. */
  49199. onTick?: (data: ITimerData<any>) => void;
  49200. }
  49201. /**
  49202. * An interface defining the data sent by the timer
  49203. */
  49204. export interface ITimerData<T> {
  49205. /**
  49206. * When did it start
  49207. */
  49208. startTime: number;
  49209. /**
  49210. * Time now
  49211. */
  49212. currentTime: number;
  49213. /**
  49214. * Time passed since started
  49215. */
  49216. deltaTime: number;
  49217. /**
  49218. * How much is completed, in [0.0...1.0].
  49219. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49220. */
  49221. completeRate: number;
  49222. /**
  49223. * What the registered observable sent in the last count
  49224. */
  49225. payload: T;
  49226. }
  49227. /**
  49228. * The current state of the timer
  49229. */
  49230. export enum TimerState {
  49231. /**
  49232. * Timer initialized, not yet started
  49233. */
  49234. INIT = 0,
  49235. /**
  49236. * Timer started and counting
  49237. */
  49238. STARTED = 1,
  49239. /**
  49240. * Timer ended (whether aborted or time reached)
  49241. */
  49242. ENDED = 2
  49243. }
  49244. /**
  49245. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49246. *
  49247. * @param options options with which to initialize this timer
  49248. */
  49249. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49250. /**
  49251. * An advanced implementation of a timer class
  49252. */
  49253. export class AdvancedTimer<T = any> implements IDisposable {
  49254. /**
  49255. * Will notify each time the timer calculates the remaining time
  49256. */
  49257. onEachCountObservable: Observable<ITimerData<T>>;
  49258. /**
  49259. * Will trigger when the timer was aborted due to the break condition
  49260. */
  49261. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49262. /**
  49263. * Will trigger when the timer ended successfully
  49264. */
  49265. onTimerEndedObservable: Observable<ITimerData<T>>;
  49266. /**
  49267. * Will trigger when the timer state has changed
  49268. */
  49269. onStateChangedObservable: Observable<TimerState>;
  49270. private _observer;
  49271. private _contextObservable;
  49272. private _observableParameters;
  49273. private _startTime;
  49274. private _timer;
  49275. private _state;
  49276. private _breakCondition;
  49277. private _timeToEnd;
  49278. private _breakOnNextTick;
  49279. /**
  49280. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49281. * @param options construction options for this advanced timer
  49282. */
  49283. constructor(options: ITimerOptions<T>);
  49284. /**
  49285. * set a breaking condition for this timer. Default is to never break during count
  49286. * @param predicate the new break condition. Returns true to break, false otherwise
  49287. */
  49288. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49289. /**
  49290. * Reset ALL associated observables in this advanced timer
  49291. */
  49292. clearObservables(): void;
  49293. /**
  49294. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49295. *
  49296. * @param timeToEnd how much time to measure until timer ended
  49297. */
  49298. start(timeToEnd?: number): void;
  49299. /**
  49300. * Will force a stop on the next tick.
  49301. */
  49302. stop(): void;
  49303. /**
  49304. * Dispose this timer, clearing all resources
  49305. */
  49306. dispose(): void;
  49307. private _setState;
  49308. private _tick;
  49309. private _stop;
  49310. }
  49311. }
  49312. declare module BABYLON {
  49313. /**
  49314. * The options container for the teleportation module
  49315. */
  49316. export interface IWebXRTeleportationOptions {
  49317. /**
  49318. * if provided, this scene will be used to render meshes.
  49319. */
  49320. customUtilityLayerScene?: Scene;
  49321. /**
  49322. * Values to configure the default target mesh
  49323. */
  49324. defaultTargetMeshOptions?: {
  49325. /**
  49326. * Fill color of the teleportation area
  49327. */
  49328. teleportationFillColor?: string;
  49329. /**
  49330. * Border color for the teleportation area
  49331. */
  49332. teleportationBorderColor?: string;
  49333. /**
  49334. * Disable the mesh's animation sequence
  49335. */
  49336. disableAnimation?: boolean;
  49337. /**
  49338. * Disable lighting on the material or the ring and arrow
  49339. */
  49340. disableLighting?: boolean;
  49341. /**
  49342. * Override the default material of the torus and arrow
  49343. */
  49344. torusArrowMaterial?: Material;
  49345. };
  49346. /**
  49347. * A list of meshes to use as floor meshes.
  49348. * Meshes can be added and removed after initializing the feature using the
  49349. * addFloorMesh and removeFloorMesh functions
  49350. * If empty, rotation will still work
  49351. */
  49352. floorMeshes?: AbstractMesh[];
  49353. /**
  49354. * use this rendering group id for the meshes (optional)
  49355. */
  49356. renderingGroupId?: number;
  49357. /**
  49358. * Should teleportation move only to snap points
  49359. */
  49360. snapPointsOnly?: boolean;
  49361. /**
  49362. * An array of points to which the teleportation will snap to.
  49363. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49364. */
  49365. snapPositions?: Vector3[];
  49366. /**
  49367. * How close should the teleportation ray be in order to snap to position.
  49368. * Default to 0.8 units (meters)
  49369. */
  49370. snapToPositionRadius?: number;
  49371. /**
  49372. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49373. * If you want to support rotation, make sure your mesh has a direction indicator.
  49374. *
  49375. * When left untouched, the default mesh will be initialized.
  49376. */
  49377. teleportationTargetMesh?: AbstractMesh;
  49378. /**
  49379. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49380. */
  49381. timeToTeleport?: number;
  49382. /**
  49383. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49384. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49385. */
  49386. useMainComponentOnly?: boolean;
  49387. /**
  49388. * Should meshes created here be added to a utility layer or the main scene
  49389. */
  49390. useUtilityLayer?: boolean;
  49391. /**
  49392. * Babylon XR Input class for controller
  49393. */
  49394. xrInput: WebXRInput;
  49395. /**
  49396. * Meshes that the teleportation ray cannot go through
  49397. */
  49398. pickBlockerMeshes?: AbstractMesh[];
  49399. }
  49400. /**
  49401. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49402. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49403. * the input of the attached controllers.
  49404. */
  49405. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49406. private _options;
  49407. private _controllers;
  49408. private _currentTeleportationControllerId;
  49409. private _floorMeshes;
  49410. private _quadraticBezierCurve;
  49411. private _selectionFeature;
  49412. private _snapToPositions;
  49413. private _snappedToPoint;
  49414. private _teleportationRingMaterial?;
  49415. private _tmpRay;
  49416. private _tmpVector;
  49417. private _tmpQuaternion;
  49418. /**
  49419. * The module's name
  49420. */
  49421. static readonly Name: string;
  49422. /**
  49423. * The (Babylon) version of this module.
  49424. * This is an integer representing the implementation version.
  49425. * This number does not correspond to the webxr specs version
  49426. */
  49427. static readonly Version: number;
  49428. /**
  49429. * Is movement backwards enabled
  49430. */
  49431. backwardsMovementEnabled: boolean;
  49432. /**
  49433. * Distance to travel when moving backwards
  49434. */
  49435. backwardsTeleportationDistance: number;
  49436. /**
  49437. * The distance from the user to the inspection point in the direction of the controller
  49438. * A higher number will allow the user to move further
  49439. * defaults to 5 (meters, in xr units)
  49440. */
  49441. parabolicCheckRadius: number;
  49442. /**
  49443. * Should the module support parabolic ray on top of direct ray
  49444. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49445. * Very helpful when moving between floors / different heights
  49446. */
  49447. parabolicRayEnabled: boolean;
  49448. /**
  49449. * How much rotation should be applied when rotating right and left
  49450. */
  49451. rotationAngle: number;
  49452. /**
  49453. * Is rotation enabled when moving forward?
  49454. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49455. */
  49456. rotationEnabled: boolean;
  49457. /**
  49458. * constructs a new anchor system
  49459. * @param _xrSessionManager an instance of WebXRSessionManager
  49460. * @param _options configuration object for this feature
  49461. */
  49462. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49463. /**
  49464. * Get the snapPointsOnly flag
  49465. */
  49466. get snapPointsOnly(): boolean;
  49467. /**
  49468. * Sets the snapPointsOnly flag
  49469. * @param snapToPoints should teleportation be exclusively to snap points
  49470. */
  49471. set snapPointsOnly(snapToPoints: boolean);
  49472. /**
  49473. * Add a new mesh to the floor meshes array
  49474. * @param mesh the mesh to use as floor mesh
  49475. */
  49476. addFloorMesh(mesh: AbstractMesh): void;
  49477. /**
  49478. * Add a new snap-to point to fix teleportation to this position
  49479. * @param newSnapPoint The new Snap-To point
  49480. */
  49481. addSnapPoint(newSnapPoint: Vector3): void;
  49482. attach(): boolean;
  49483. detach(): boolean;
  49484. dispose(): void;
  49485. /**
  49486. * Remove a mesh from the floor meshes array
  49487. * @param mesh the mesh to remove
  49488. */
  49489. removeFloorMesh(mesh: AbstractMesh): void;
  49490. /**
  49491. * Remove a mesh from the floor meshes array using its name
  49492. * @param name the mesh name to remove
  49493. */
  49494. removeFloorMeshByName(name: string): void;
  49495. /**
  49496. * 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
  49497. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49498. * @returns was the point found and removed or not
  49499. */
  49500. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49501. /**
  49502. * This function sets a selection feature that will be disabled when
  49503. * the forward ray is shown and will be reattached when hidden.
  49504. * This is used to remove the selection rays when moving.
  49505. * @param selectionFeature the feature to disable when forward movement is enabled
  49506. */
  49507. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49508. protected _onXRFrame(_xrFrame: XRFrame): void;
  49509. private _attachController;
  49510. private _createDefaultTargetMesh;
  49511. private _detachController;
  49512. private _findClosestSnapPointWithRadius;
  49513. private _setTargetMeshPosition;
  49514. private _setTargetMeshVisibility;
  49515. private _showParabolicPath;
  49516. private _teleportForward;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * Options for the default xr helper
  49522. */
  49523. export class WebXRDefaultExperienceOptions {
  49524. /**
  49525. * Enable or disable default UI to enter XR
  49526. */
  49527. disableDefaultUI?: boolean;
  49528. /**
  49529. * Should teleportation not initialize. defaults to false.
  49530. */
  49531. disableTeleportation?: boolean;
  49532. /**
  49533. * Floor meshes that will be used for teleport
  49534. */
  49535. floorMeshes?: Array<AbstractMesh>;
  49536. /**
  49537. * If set to true, the first frame will not be used to reset position
  49538. * The first frame is mainly used when copying transformation from the old camera
  49539. * Mainly used in AR
  49540. */
  49541. ignoreNativeCameraTransformation?: boolean;
  49542. /**
  49543. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49544. */
  49545. inputOptions?: IWebXRInputOptions;
  49546. /**
  49547. * optional configuration for the output canvas
  49548. */
  49549. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49550. /**
  49551. * optional UI options. This can be used among other to change session mode and reference space type
  49552. */
  49553. uiOptions?: WebXREnterExitUIOptions;
  49554. /**
  49555. * When loading teleportation and pointer select, use stable versions instead of latest.
  49556. */
  49557. useStablePlugins?: boolean;
  49558. /**
  49559. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49560. */
  49561. renderingGroupId?: number;
  49562. /**
  49563. * A list of optional features to init the session with
  49564. * If set to true, all features we support will be added
  49565. */
  49566. optionalFeatures?: boolean | string[];
  49567. }
  49568. /**
  49569. * Default experience which provides a similar setup to the previous webVRExperience
  49570. */
  49571. export class WebXRDefaultExperience {
  49572. /**
  49573. * Base experience
  49574. */
  49575. baseExperience: WebXRExperienceHelper;
  49576. /**
  49577. * Enables ui for entering/exiting xr
  49578. */
  49579. enterExitUI: WebXREnterExitUI;
  49580. /**
  49581. * Input experience extension
  49582. */
  49583. input: WebXRInput;
  49584. /**
  49585. * Enables laser pointer and selection
  49586. */
  49587. pointerSelection: WebXRControllerPointerSelection;
  49588. /**
  49589. * Default target xr should render to
  49590. */
  49591. renderTarget: WebXRRenderTarget;
  49592. /**
  49593. * Enables teleportation
  49594. */
  49595. teleportation: WebXRMotionControllerTeleportation;
  49596. private constructor();
  49597. /**
  49598. * Creates the default xr experience
  49599. * @param scene scene
  49600. * @param options options for basic configuration
  49601. * @returns resulting WebXRDefaultExperience
  49602. */
  49603. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49604. /**
  49605. * DIsposes of the experience helper
  49606. */
  49607. dispose(): void;
  49608. }
  49609. }
  49610. declare module BABYLON {
  49611. /**
  49612. * Options to modify the vr teleportation behavior.
  49613. */
  49614. export interface VRTeleportationOptions {
  49615. /**
  49616. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49617. */
  49618. floorMeshName?: string;
  49619. /**
  49620. * A list of meshes to be used as the teleportation floor. (default: empty)
  49621. */
  49622. floorMeshes?: Mesh[];
  49623. /**
  49624. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49625. */
  49626. teleportationMode?: number;
  49627. /**
  49628. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49629. */
  49630. teleportationTime?: number;
  49631. /**
  49632. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49633. */
  49634. teleportationSpeed?: number;
  49635. /**
  49636. * The easing function used in the animation or null for Linear. (default CircleEase)
  49637. */
  49638. easingFunction?: EasingFunction;
  49639. }
  49640. /**
  49641. * Options to modify the vr experience helper's behavior.
  49642. */
  49643. export interface VRExperienceHelperOptions extends WebVROptions {
  49644. /**
  49645. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49646. */
  49647. createDeviceOrientationCamera?: boolean;
  49648. /**
  49649. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49650. */
  49651. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49652. /**
  49653. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49654. */
  49655. laserToggle?: boolean;
  49656. /**
  49657. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49658. */
  49659. floorMeshes?: Mesh[];
  49660. /**
  49661. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49662. */
  49663. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49664. /**
  49665. * Defines if WebXR should be used instead of WebVR (if available)
  49666. */
  49667. useXR?: boolean;
  49668. }
  49669. /**
  49670. * Event containing information after VR has been entered
  49671. */
  49672. export class OnAfterEnteringVRObservableEvent {
  49673. /**
  49674. * If entering vr was successful
  49675. */
  49676. success: boolean;
  49677. }
  49678. /**
  49679. * Helps to quickly add VR support to an existing scene.
  49680. * See https://doc.babylonjs.com/how_to/webvr_helper
  49681. */
  49682. export class VRExperienceHelper {
  49683. /** Options to modify the vr experience helper's behavior. */
  49684. webVROptions: VRExperienceHelperOptions;
  49685. private _scene;
  49686. private _position;
  49687. private _btnVR;
  49688. private _btnVRDisplayed;
  49689. private _webVRsupported;
  49690. private _webVRready;
  49691. private _webVRrequesting;
  49692. private _webVRpresenting;
  49693. private _hasEnteredVR;
  49694. private _fullscreenVRpresenting;
  49695. private _inputElement;
  49696. private _webVRCamera;
  49697. private _vrDeviceOrientationCamera;
  49698. private _deviceOrientationCamera;
  49699. private _existingCamera;
  49700. private _onKeyDown;
  49701. private _onVrDisplayPresentChange;
  49702. private _onVRDisplayChanged;
  49703. private _onVRRequestPresentStart;
  49704. private _onVRRequestPresentComplete;
  49705. /**
  49706. * 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)
  49707. */
  49708. enableGazeEvenWhenNoPointerLock: boolean;
  49709. /**
  49710. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49711. */
  49712. exitVROnDoubleTap: boolean;
  49713. /**
  49714. * Observable raised right before entering VR.
  49715. */
  49716. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49717. /**
  49718. * Observable raised when entering VR has completed.
  49719. */
  49720. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49721. /**
  49722. * Observable raised when exiting VR.
  49723. */
  49724. onExitingVRObservable: Observable<VRExperienceHelper>;
  49725. /**
  49726. * Observable raised when controller mesh is loaded.
  49727. */
  49728. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49729. /** Return this.onEnteringVRObservable
  49730. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49731. */
  49732. get onEnteringVR(): Observable<VRExperienceHelper>;
  49733. /** Return this.onExitingVRObservable
  49734. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49735. */
  49736. get onExitingVR(): Observable<VRExperienceHelper>;
  49737. /** Return this.onControllerMeshLoadedObservable
  49738. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49739. */
  49740. get onControllerMeshLoaded(): Observable<WebVRController>;
  49741. private _rayLength;
  49742. private _useCustomVRButton;
  49743. private _teleportationRequested;
  49744. private _teleportActive;
  49745. private _floorMeshName;
  49746. private _floorMeshesCollection;
  49747. private _teleportationMode;
  49748. private _teleportationTime;
  49749. private _teleportationSpeed;
  49750. private _teleportationEasing;
  49751. private _rotationAllowed;
  49752. private _teleportBackwardsVector;
  49753. private _teleportationTarget;
  49754. private _isDefaultTeleportationTarget;
  49755. private _postProcessMove;
  49756. private _teleportationFillColor;
  49757. private _teleportationBorderColor;
  49758. private _rotationAngle;
  49759. private _haloCenter;
  49760. private _cameraGazer;
  49761. private _padSensibilityUp;
  49762. private _padSensibilityDown;
  49763. private _leftController;
  49764. private _rightController;
  49765. private _gazeColor;
  49766. private _laserColor;
  49767. private _pickedLaserColor;
  49768. private _pickedGazeColor;
  49769. /**
  49770. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49771. */
  49772. onNewMeshSelected: Observable<AbstractMesh>;
  49773. /**
  49774. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49775. * This observable will provide the mesh and the controller used to select the mesh
  49776. */
  49777. onMeshSelectedWithController: Observable<{
  49778. mesh: AbstractMesh;
  49779. controller: WebVRController;
  49780. }>;
  49781. /**
  49782. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49783. */
  49784. onNewMeshPicked: Observable<PickingInfo>;
  49785. private _circleEase;
  49786. /**
  49787. * Observable raised before camera teleportation
  49788. */
  49789. onBeforeCameraTeleport: Observable<Vector3>;
  49790. /**
  49791. * Observable raised after camera teleportation
  49792. */
  49793. onAfterCameraTeleport: Observable<Vector3>;
  49794. /**
  49795. * Observable raised when current selected mesh gets unselected
  49796. */
  49797. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49798. private _raySelectionPredicate;
  49799. /**
  49800. * To be optionaly changed by user to define custom ray selection
  49801. */
  49802. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49803. /**
  49804. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49805. */
  49806. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49807. /**
  49808. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49809. */
  49810. teleportationEnabled: boolean;
  49811. private _defaultHeight;
  49812. private _teleportationInitialized;
  49813. private _interactionsEnabled;
  49814. private _interactionsRequested;
  49815. private _displayGaze;
  49816. private _displayLaserPointer;
  49817. /**
  49818. * The mesh used to display where the user is going to teleport.
  49819. */
  49820. get teleportationTarget(): Mesh;
  49821. /**
  49822. * Sets the mesh to be used to display where the user is going to teleport.
  49823. */
  49824. set teleportationTarget(value: Mesh);
  49825. /**
  49826. * 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
  49827. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49828. * See https://doc.babylonjs.com/resources/baking_transformations
  49829. */
  49830. get gazeTrackerMesh(): Mesh;
  49831. set gazeTrackerMesh(value: Mesh);
  49832. /**
  49833. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49834. */
  49835. updateGazeTrackerScale: boolean;
  49836. /**
  49837. * If the gaze trackers color should be updated when selecting meshes
  49838. */
  49839. updateGazeTrackerColor: boolean;
  49840. /**
  49841. * If the controller laser color should be updated when selecting meshes
  49842. */
  49843. updateControllerLaserColor: boolean;
  49844. /**
  49845. * The gaze tracking mesh corresponding to the left controller
  49846. */
  49847. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49848. /**
  49849. * The gaze tracking mesh corresponding to the right controller
  49850. */
  49851. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49852. /**
  49853. * If the ray of the gaze should be displayed.
  49854. */
  49855. get displayGaze(): boolean;
  49856. /**
  49857. * Sets if the ray of the gaze should be displayed.
  49858. */
  49859. set displayGaze(value: boolean);
  49860. /**
  49861. * If the ray of the LaserPointer should be displayed.
  49862. */
  49863. get displayLaserPointer(): boolean;
  49864. /**
  49865. * Sets if the ray of the LaserPointer should be displayed.
  49866. */
  49867. set displayLaserPointer(value: boolean);
  49868. /**
  49869. * The deviceOrientationCamera used as the camera when not in VR.
  49870. */
  49871. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49872. /**
  49873. * Based on the current WebVR support, returns the current VR camera used.
  49874. */
  49875. get currentVRCamera(): Nullable<Camera>;
  49876. /**
  49877. * The webVRCamera which is used when in VR.
  49878. */
  49879. get webVRCamera(): WebVRFreeCamera;
  49880. /**
  49881. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49882. */
  49883. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49884. /**
  49885. * The html button that is used to trigger entering into VR.
  49886. */
  49887. get vrButton(): Nullable<HTMLButtonElement>;
  49888. private get _teleportationRequestInitiated();
  49889. /**
  49890. * Defines whether or not Pointer lock should be requested when switching to
  49891. * full screen.
  49892. */
  49893. requestPointerLockOnFullScreen: boolean;
  49894. /**
  49895. * If asking to force XR, this will be populated with the default xr experience
  49896. */
  49897. xr: WebXRDefaultExperience;
  49898. /**
  49899. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49900. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49901. */
  49902. xrTestDone: boolean;
  49903. /**
  49904. * Instantiates a VRExperienceHelper.
  49905. * Helps to quickly add VR support to an existing scene.
  49906. * @param scene The scene the VRExperienceHelper belongs to.
  49907. * @param webVROptions Options to modify the vr experience helper's behavior.
  49908. */
  49909. constructor(scene: Scene,
  49910. /** Options to modify the vr experience helper's behavior. */
  49911. webVROptions?: VRExperienceHelperOptions);
  49912. private completeVRInit;
  49913. private _onDefaultMeshLoaded;
  49914. private _onResize;
  49915. private _onFullscreenChange;
  49916. /**
  49917. * Gets a value indicating if we are currently in VR mode.
  49918. */
  49919. get isInVRMode(): boolean;
  49920. private onVrDisplayPresentChange;
  49921. private onVRDisplayChanged;
  49922. private moveButtonToBottomRight;
  49923. private displayVRButton;
  49924. private updateButtonVisibility;
  49925. private _cachedAngularSensibility;
  49926. /**
  49927. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49928. * Otherwise, will use the fullscreen API.
  49929. */
  49930. enterVR(): void;
  49931. /**
  49932. * Attempt to exit VR, or fullscreen.
  49933. */
  49934. exitVR(): void;
  49935. /**
  49936. * The position of the vr experience helper.
  49937. */
  49938. get position(): Vector3;
  49939. /**
  49940. * Sets the position of the vr experience helper.
  49941. */
  49942. set position(value: Vector3);
  49943. /**
  49944. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49945. */
  49946. enableInteractions(): void;
  49947. private get _noControllerIsActive();
  49948. private beforeRender;
  49949. private _isTeleportationFloor;
  49950. /**
  49951. * Adds a floor mesh to be used for teleportation.
  49952. * @param floorMesh the mesh to be used for teleportation.
  49953. */
  49954. addFloorMesh(floorMesh: Mesh): void;
  49955. /**
  49956. * Removes a floor mesh from being used for teleportation.
  49957. * @param floorMesh the mesh to be removed.
  49958. */
  49959. removeFloorMesh(floorMesh: Mesh): void;
  49960. /**
  49961. * Enables interactions and teleportation using the VR controllers and gaze.
  49962. * @param vrTeleportationOptions options to modify teleportation behavior.
  49963. */
  49964. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49965. private _onNewGamepadConnected;
  49966. private _tryEnableInteractionOnController;
  49967. private _onNewGamepadDisconnected;
  49968. private _enableInteractionOnController;
  49969. private _checkTeleportWithRay;
  49970. private _checkRotate;
  49971. private _checkTeleportBackwards;
  49972. private _enableTeleportationOnController;
  49973. private _createTeleportationCircles;
  49974. private _displayTeleportationTarget;
  49975. private _hideTeleportationTarget;
  49976. private _rotateCamera;
  49977. private _moveTeleportationSelectorTo;
  49978. private _workingVector;
  49979. private _workingQuaternion;
  49980. private _workingMatrix;
  49981. /**
  49982. * Time Constant Teleportation Mode
  49983. */
  49984. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49985. /**
  49986. * Speed Constant Teleportation Mode
  49987. */
  49988. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49989. /**
  49990. * Teleports the users feet to the desired location
  49991. * @param location The location where the user's feet should be placed
  49992. */
  49993. teleportCamera(location: Vector3): void;
  49994. private _convertNormalToDirectionOfRay;
  49995. private _castRayAndSelectObject;
  49996. private _notifySelectedMeshUnselected;
  49997. /**
  49998. * Permanently set new colors for the laser pointer
  49999. * @param color the new laser color
  50000. * @param pickedColor the new laser color when picked mesh detected
  50001. */
  50002. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50003. /**
  50004. * Set lighting enabled / disabled on the laser pointer of both controllers
  50005. * @param enabled should the lighting be enabled on the laser pointer
  50006. */
  50007. setLaserLightingState(enabled?: boolean): void;
  50008. /**
  50009. * Permanently set new colors for the gaze pointer
  50010. * @param color the new gaze color
  50011. * @param pickedColor the new gaze color when picked mesh detected
  50012. */
  50013. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50014. /**
  50015. * Sets the color of the laser ray from the vr controllers.
  50016. * @param color new color for the ray.
  50017. */
  50018. changeLaserColor(color: Color3): void;
  50019. /**
  50020. * Sets the color of the ray from the vr headsets gaze.
  50021. * @param color new color for the ray.
  50022. */
  50023. changeGazeColor(color: Color3): void;
  50024. /**
  50025. * Exits VR and disposes of the vr experience helper
  50026. */
  50027. dispose(): void;
  50028. /**
  50029. * Gets the name of the VRExperienceHelper class
  50030. * @returns "VRExperienceHelper"
  50031. */
  50032. getClassName(): string;
  50033. }
  50034. }
  50035. declare module BABYLON {
  50036. /**
  50037. * Contains an array of blocks representing the octree
  50038. */
  50039. export interface IOctreeContainer<T> {
  50040. /**
  50041. * Blocks within the octree
  50042. */
  50043. blocks: Array<OctreeBlock<T>>;
  50044. }
  50045. /**
  50046. * Class used to store a cell in an octree
  50047. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50048. */
  50049. export class OctreeBlock<T> {
  50050. /**
  50051. * Gets the content of the current block
  50052. */
  50053. entries: T[];
  50054. /**
  50055. * Gets the list of block children
  50056. */
  50057. blocks: Array<OctreeBlock<T>>;
  50058. private _depth;
  50059. private _maxDepth;
  50060. private _capacity;
  50061. private _minPoint;
  50062. private _maxPoint;
  50063. private _boundingVectors;
  50064. private _creationFunc;
  50065. /**
  50066. * Creates a new block
  50067. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50068. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50069. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50070. * @param depth defines the current depth of this block in the octree
  50071. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50072. * @param creationFunc defines a callback to call when an element is added to the block
  50073. */
  50074. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50075. /**
  50076. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50077. */
  50078. get capacity(): number;
  50079. /**
  50080. * Gets the minimum vector (in world space) of the block's bounding box
  50081. */
  50082. get minPoint(): Vector3;
  50083. /**
  50084. * Gets the maximum vector (in world space) of the block's bounding box
  50085. */
  50086. get maxPoint(): Vector3;
  50087. /**
  50088. * Add a new element to this block
  50089. * @param entry defines the element to add
  50090. */
  50091. addEntry(entry: T): void;
  50092. /**
  50093. * Remove an element from this block
  50094. * @param entry defines the element to remove
  50095. */
  50096. removeEntry(entry: T): void;
  50097. /**
  50098. * Add an array of elements to this block
  50099. * @param entries defines the array of elements to add
  50100. */
  50101. addEntries(entries: T[]): void;
  50102. /**
  50103. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50104. * @param frustumPlanes defines the frustum planes to test
  50105. * @param selection defines the array to store current content if selection is positive
  50106. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50107. */
  50108. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50109. /**
  50110. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50111. * @param sphereCenter defines the bounding sphere center
  50112. * @param sphereRadius defines the bounding sphere radius
  50113. * @param selection defines the array to store current content if selection is positive
  50114. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50115. */
  50116. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50117. /**
  50118. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50119. * @param ray defines the ray to test with
  50120. * @param selection defines the array to store current content if selection is positive
  50121. */
  50122. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50123. /**
  50124. * Subdivide the content into child blocks (this block will then be empty)
  50125. */
  50126. createInnerBlocks(): void;
  50127. /**
  50128. * @hidden
  50129. */
  50130. 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;
  50131. }
  50132. }
  50133. declare module BABYLON {
  50134. /**
  50135. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50136. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50137. */
  50138. export class Octree<T> {
  50139. /** 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.) */
  50140. maxDepth: number;
  50141. /**
  50142. * Blocks within the octree containing objects
  50143. */
  50144. blocks: Array<OctreeBlock<T>>;
  50145. /**
  50146. * Content stored in the octree
  50147. */
  50148. dynamicContent: T[];
  50149. private _maxBlockCapacity;
  50150. private _selectionContent;
  50151. private _creationFunc;
  50152. /**
  50153. * Creates a octree
  50154. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50155. * @param creationFunc function to be used to instatiate the octree
  50156. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50157. * @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.)
  50158. */
  50159. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50160. /** 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.) */
  50161. maxDepth?: number);
  50162. /**
  50163. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50164. * @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);
  50165. * @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);
  50166. * @param entries meshes to be added to the octree blocks
  50167. */
  50168. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50169. /**
  50170. * Adds a mesh to the octree
  50171. * @param entry Mesh to add to the octree
  50172. */
  50173. addMesh(entry: T): void;
  50174. /**
  50175. * Remove an element from the octree
  50176. * @param entry defines the element to remove
  50177. */
  50178. removeMesh(entry: T): void;
  50179. /**
  50180. * Selects an array of meshes within the frustum
  50181. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50182. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50183. * @returns array of meshes within the frustum
  50184. */
  50185. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50186. /**
  50187. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50188. * @param sphereCenter defines the bounding sphere center
  50189. * @param sphereRadius defines the bounding sphere radius
  50190. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50191. * @returns an array of objects that intersect the sphere
  50192. */
  50193. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50194. /**
  50195. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50196. * @param ray defines the ray to test with
  50197. * @returns array of intersected objects
  50198. */
  50199. intersectsRay(ray: Ray): SmartArray<T>;
  50200. /**
  50201. * Adds a mesh into the octree block if it intersects the block
  50202. */
  50203. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50204. /**
  50205. * Adds a submesh into the octree block if it intersects the block
  50206. */
  50207. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50208. }
  50209. }
  50210. declare module BABYLON {
  50211. interface Scene {
  50212. /**
  50213. * @hidden
  50214. * Backing Filed
  50215. */
  50216. _selectionOctree: Octree<AbstractMesh>;
  50217. /**
  50218. * Gets the octree used to boost mesh selection (picking)
  50219. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50220. */
  50221. selectionOctree: Octree<AbstractMesh>;
  50222. /**
  50223. * Creates or updates the octree used to boost selection (picking)
  50224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50225. * @param maxCapacity defines the maximum capacity per leaf
  50226. * @param maxDepth defines the maximum depth of the octree
  50227. * @returns an octree of AbstractMesh
  50228. */
  50229. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50230. }
  50231. interface AbstractMesh {
  50232. /**
  50233. * @hidden
  50234. * Backing Field
  50235. */
  50236. _submeshesOctree: Octree<SubMesh>;
  50237. /**
  50238. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50239. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50240. * @param maxCapacity defines the maximum size of each block (64 by default)
  50241. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50242. * @returns the new octree
  50243. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50244. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50245. */
  50246. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50247. }
  50248. /**
  50249. * Defines the octree scene component responsible to manage any octrees
  50250. * in a given scene.
  50251. */
  50252. export class OctreeSceneComponent {
  50253. /**
  50254. * The component name help to identify the component in the list of scene components.
  50255. */
  50256. readonly name: string;
  50257. /**
  50258. * The scene the component belongs to.
  50259. */
  50260. scene: Scene;
  50261. /**
  50262. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50263. */
  50264. readonly checksIsEnabled: boolean;
  50265. /**
  50266. * Creates a new instance of the component for the given scene
  50267. * @param scene Defines the scene to register the component in
  50268. */
  50269. constructor(scene: Scene);
  50270. /**
  50271. * Registers the component in a given scene
  50272. */
  50273. register(): void;
  50274. /**
  50275. * Return the list of active meshes
  50276. * @returns the list of active meshes
  50277. */
  50278. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50279. /**
  50280. * Return the list of active sub meshes
  50281. * @param mesh The mesh to get the candidates sub meshes from
  50282. * @returns the list of active sub meshes
  50283. */
  50284. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50285. private _tempRay;
  50286. /**
  50287. * Return the list of sub meshes intersecting with a given local ray
  50288. * @param mesh defines the mesh to find the submesh for
  50289. * @param localRay defines the ray in local space
  50290. * @returns the list of intersecting sub meshes
  50291. */
  50292. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50293. /**
  50294. * Return the list of sub meshes colliding with a collider
  50295. * @param mesh defines the mesh to find the submesh for
  50296. * @param collider defines the collider to evaluate the collision against
  50297. * @returns the list of colliding sub meshes
  50298. */
  50299. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50300. /**
  50301. * Rebuilds the elements related to this component in case of
  50302. * context lost for instance.
  50303. */
  50304. rebuild(): void;
  50305. /**
  50306. * Disposes the component and the associated ressources.
  50307. */
  50308. dispose(): void;
  50309. }
  50310. }
  50311. declare module BABYLON {
  50312. /**
  50313. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50314. */
  50315. export class Gizmo implements IDisposable {
  50316. /** The utility layer the gizmo will be added to */
  50317. gizmoLayer: UtilityLayerRenderer;
  50318. /**
  50319. * The root mesh of the gizmo
  50320. */
  50321. _rootMesh: Mesh;
  50322. private _attachedMesh;
  50323. private _attachedNode;
  50324. /**
  50325. * Ratio for the scale of the gizmo (Default: 1)
  50326. */
  50327. protected _scaleRatio: number;
  50328. /**
  50329. * Ratio for the scale of the gizmo (Default: 1)
  50330. */
  50331. set scaleRatio(value: number);
  50332. get scaleRatio(): number;
  50333. /**
  50334. * If a custom mesh has been set (Default: false)
  50335. */
  50336. protected _customMeshSet: boolean;
  50337. /**
  50338. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50339. * * When set, interactions will be enabled
  50340. */
  50341. get attachedMesh(): Nullable<AbstractMesh>;
  50342. set attachedMesh(value: Nullable<AbstractMesh>);
  50343. /**
  50344. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50345. * * When set, interactions will be enabled
  50346. */
  50347. get attachedNode(): Nullable<Node>;
  50348. set attachedNode(value: Nullable<Node>);
  50349. /**
  50350. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50351. * @param mesh The mesh to replace the default mesh of the gizmo
  50352. */
  50353. setCustomMesh(mesh: Mesh): void;
  50354. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50355. /**
  50356. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50357. */
  50358. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50359. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50360. /**
  50361. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50362. */
  50363. updateGizmoPositionToMatchAttachedMesh: boolean;
  50364. /**
  50365. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50366. */
  50367. updateScale: boolean;
  50368. protected _interactionsEnabled: boolean;
  50369. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50370. private _beforeRenderObserver;
  50371. private _tempQuaternion;
  50372. private _tempVector;
  50373. private _tempVector2;
  50374. private _tempMatrix1;
  50375. private _tempMatrix2;
  50376. private _rightHandtoLeftHandMatrix;
  50377. /**
  50378. * Creates a gizmo
  50379. * @param gizmoLayer The utility layer the gizmo will be added to
  50380. */
  50381. constructor(
  50382. /** The utility layer the gizmo will be added to */
  50383. gizmoLayer?: UtilityLayerRenderer);
  50384. /**
  50385. * Updates the gizmo to match the attached mesh's position/rotation
  50386. */
  50387. protected _update(): void;
  50388. /**
  50389. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50390. * @param value Node, TransformNode or mesh
  50391. */
  50392. protected _matrixChanged(): void;
  50393. /**
  50394. * Disposes of the gizmo
  50395. */
  50396. dispose(): void;
  50397. }
  50398. }
  50399. declare module BABYLON {
  50400. /**
  50401. * Single plane drag gizmo
  50402. */
  50403. export class PlaneDragGizmo extends Gizmo {
  50404. /**
  50405. * Drag behavior responsible for the gizmos dragging interactions
  50406. */
  50407. dragBehavior: PointerDragBehavior;
  50408. private _pointerObserver;
  50409. /**
  50410. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50411. */
  50412. snapDistance: number;
  50413. /**
  50414. * Event that fires each time the gizmo snaps to a new location.
  50415. * * snapDistance is the the change in distance
  50416. */
  50417. onSnapObservable: Observable<{
  50418. snapDistance: number;
  50419. }>;
  50420. private _plane;
  50421. private _coloredMaterial;
  50422. private _hoverMaterial;
  50423. private _isEnabled;
  50424. private _parent;
  50425. /** @hidden */
  50426. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50427. /** @hidden */
  50428. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50429. /**
  50430. * Creates a PlaneDragGizmo
  50431. * @param gizmoLayer The utility layer the gizmo will be added to
  50432. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50433. * @param color The color of the gizmo
  50434. */
  50435. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50436. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50437. /**
  50438. * If the gizmo is enabled
  50439. */
  50440. set isEnabled(value: boolean);
  50441. get isEnabled(): boolean;
  50442. /**
  50443. * Disposes of the gizmo
  50444. */
  50445. dispose(): void;
  50446. }
  50447. }
  50448. declare module BABYLON {
  50449. /**
  50450. * Gizmo that enables dragging a mesh along 3 axis
  50451. */
  50452. export class PositionGizmo extends Gizmo {
  50453. /**
  50454. * Internal gizmo used for interactions on the x axis
  50455. */
  50456. xGizmo: AxisDragGizmo;
  50457. /**
  50458. * Internal gizmo used for interactions on the y axis
  50459. */
  50460. yGizmo: AxisDragGizmo;
  50461. /**
  50462. * Internal gizmo used for interactions on the z axis
  50463. */
  50464. zGizmo: AxisDragGizmo;
  50465. /**
  50466. * Internal gizmo used for interactions on the yz plane
  50467. */
  50468. xPlaneGizmo: PlaneDragGizmo;
  50469. /**
  50470. * Internal gizmo used for interactions on the xz plane
  50471. */
  50472. yPlaneGizmo: PlaneDragGizmo;
  50473. /**
  50474. * Internal gizmo used for interactions on the xy plane
  50475. */
  50476. zPlaneGizmo: PlaneDragGizmo;
  50477. /**
  50478. * private variables
  50479. */
  50480. private _meshAttached;
  50481. private _nodeAttached;
  50482. private _snapDistance;
  50483. /** Fires an event when any of it's sub gizmos are dragged */
  50484. onDragStartObservable: Observable<unknown>;
  50485. /** Fires an event when any of it's sub gizmos are released from dragging */
  50486. onDragEndObservable: Observable<unknown>;
  50487. /**
  50488. * If set to true, planar drag is enabled
  50489. */
  50490. private _planarGizmoEnabled;
  50491. get attachedMesh(): Nullable<AbstractMesh>;
  50492. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50493. get attachedNode(): Nullable<Node>;
  50494. set attachedNode(node: Nullable<Node>);
  50495. /**
  50496. * Creates a PositionGizmo
  50497. * @param gizmoLayer The utility layer the gizmo will be added to
  50498. @param thickness display gizmo axis thickness
  50499. */
  50500. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50501. /**
  50502. * If the planar drag gizmo is enabled
  50503. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50504. */
  50505. set planarGizmoEnabled(value: boolean);
  50506. get planarGizmoEnabled(): boolean;
  50507. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50508. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50509. /**
  50510. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50511. */
  50512. set snapDistance(value: number);
  50513. get snapDistance(): number;
  50514. /**
  50515. * Ratio for the scale of the gizmo (Default: 1)
  50516. */
  50517. set scaleRatio(value: number);
  50518. get scaleRatio(): number;
  50519. /**
  50520. * Disposes of the gizmo
  50521. */
  50522. dispose(): void;
  50523. /**
  50524. * CustomMeshes are not supported by this gizmo
  50525. * @param mesh The mesh to replace the default mesh of the gizmo
  50526. */
  50527. setCustomMesh(mesh: Mesh): void;
  50528. }
  50529. }
  50530. declare module BABYLON {
  50531. /**
  50532. * Single axis drag gizmo
  50533. */
  50534. export class AxisDragGizmo extends Gizmo {
  50535. /**
  50536. * Drag behavior responsible for the gizmos dragging interactions
  50537. */
  50538. dragBehavior: PointerDragBehavior;
  50539. private _pointerObserver;
  50540. /**
  50541. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50542. */
  50543. snapDistance: number;
  50544. /**
  50545. * Event that fires each time the gizmo snaps to a new location.
  50546. * * snapDistance is the the change in distance
  50547. */
  50548. onSnapObservable: Observable<{
  50549. snapDistance: number;
  50550. }>;
  50551. private _isEnabled;
  50552. private _parent;
  50553. private _arrow;
  50554. private _coloredMaterial;
  50555. private _hoverMaterial;
  50556. /** @hidden */
  50557. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50558. /** @hidden */
  50559. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50560. /**
  50561. * Creates an AxisDragGizmo
  50562. * @param gizmoLayer The utility layer the gizmo will be added to
  50563. * @param dragAxis The axis which the gizmo will be able to drag on
  50564. * @param color The color of the gizmo
  50565. * @param thickness display gizmo axis thickness
  50566. */
  50567. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50568. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50569. /**
  50570. * If the gizmo is enabled
  50571. */
  50572. set isEnabled(value: boolean);
  50573. get isEnabled(): boolean;
  50574. /**
  50575. * Disposes of the gizmo
  50576. */
  50577. dispose(): void;
  50578. }
  50579. }
  50580. declare module BABYLON.Debug {
  50581. /**
  50582. * The Axes viewer will show 3 axes in a specific point in space
  50583. */
  50584. export class AxesViewer {
  50585. private _xAxis;
  50586. private _yAxis;
  50587. private _zAxis;
  50588. private _scaleLinesFactor;
  50589. private _instanced;
  50590. /**
  50591. * Gets the hosting scene
  50592. */
  50593. scene: Nullable<Scene>;
  50594. /**
  50595. * Gets or sets a number used to scale line length
  50596. */
  50597. scaleLines: number;
  50598. /** Gets the node hierarchy used to render x-axis */
  50599. get xAxis(): TransformNode;
  50600. /** Gets the node hierarchy used to render y-axis */
  50601. get yAxis(): TransformNode;
  50602. /** Gets the node hierarchy used to render z-axis */
  50603. get zAxis(): TransformNode;
  50604. /**
  50605. * Creates a new AxesViewer
  50606. * @param scene defines the hosting scene
  50607. * @param scaleLines defines a number used to scale line length (1 by default)
  50608. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50609. * @param xAxis defines the node hierarchy used to render the x-axis
  50610. * @param yAxis defines the node hierarchy used to render the y-axis
  50611. * @param zAxis defines the node hierarchy used to render the z-axis
  50612. */
  50613. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50614. /**
  50615. * Force the viewer to update
  50616. * @param position defines the position of the viewer
  50617. * @param xaxis defines the x axis of the viewer
  50618. * @param yaxis defines the y axis of the viewer
  50619. * @param zaxis defines the z axis of the viewer
  50620. */
  50621. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50622. /**
  50623. * Creates an instance of this axes viewer.
  50624. * @returns a new axes viewer with instanced meshes
  50625. */
  50626. createInstance(): AxesViewer;
  50627. /** Releases resources */
  50628. dispose(): void;
  50629. private static _SetRenderingGroupId;
  50630. }
  50631. }
  50632. declare module BABYLON.Debug {
  50633. /**
  50634. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50635. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50636. */
  50637. export class BoneAxesViewer extends AxesViewer {
  50638. /**
  50639. * Gets or sets the target mesh where to display the axes viewer
  50640. */
  50641. mesh: Nullable<Mesh>;
  50642. /**
  50643. * Gets or sets the target bone where to display the axes viewer
  50644. */
  50645. bone: Nullable<Bone>;
  50646. /** Gets current position */
  50647. pos: Vector3;
  50648. /** Gets direction of X axis */
  50649. xaxis: Vector3;
  50650. /** Gets direction of Y axis */
  50651. yaxis: Vector3;
  50652. /** Gets direction of Z axis */
  50653. zaxis: Vector3;
  50654. /**
  50655. * Creates a new BoneAxesViewer
  50656. * @param scene defines the hosting scene
  50657. * @param bone defines the target bone
  50658. * @param mesh defines the target mesh
  50659. * @param scaleLines defines a scaling factor for line length (1 by default)
  50660. */
  50661. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50662. /**
  50663. * Force the viewer to update
  50664. */
  50665. update(): void;
  50666. /** Releases resources */
  50667. dispose(): void;
  50668. }
  50669. }
  50670. declare module BABYLON {
  50671. /**
  50672. * Interface used to define scene explorer extensibility option
  50673. */
  50674. export interface IExplorerExtensibilityOption {
  50675. /**
  50676. * Define the option label
  50677. */
  50678. label: string;
  50679. /**
  50680. * Defines the action to execute on click
  50681. */
  50682. action: (entity: any) => void;
  50683. }
  50684. /**
  50685. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50686. */
  50687. export interface IExplorerExtensibilityGroup {
  50688. /**
  50689. * Defines a predicate to test if a given type mut be extended
  50690. */
  50691. predicate: (entity: any) => boolean;
  50692. /**
  50693. * Gets the list of options added to a type
  50694. */
  50695. entries: IExplorerExtensibilityOption[];
  50696. }
  50697. /**
  50698. * Interface used to define the options to use to create the Inspector
  50699. */
  50700. export interface IInspectorOptions {
  50701. /**
  50702. * Display in overlay mode (default: false)
  50703. */
  50704. overlay?: boolean;
  50705. /**
  50706. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50707. */
  50708. globalRoot?: HTMLElement;
  50709. /**
  50710. * Display the Scene explorer
  50711. */
  50712. showExplorer?: boolean;
  50713. /**
  50714. * Display the property inspector
  50715. */
  50716. showInspector?: boolean;
  50717. /**
  50718. * Display in embed mode (both panes on the right)
  50719. */
  50720. embedMode?: boolean;
  50721. /**
  50722. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50723. */
  50724. handleResize?: boolean;
  50725. /**
  50726. * Allow the panes to popup (default: true)
  50727. */
  50728. enablePopup?: boolean;
  50729. /**
  50730. * Allow the panes to be closed by users (default: true)
  50731. */
  50732. enableClose?: boolean;
  50733. /**
  50734. * Optional list of extensibility entries
  50735. */
  50736. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50737. /**
  50738. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50739. */
  50740. inspectorURL?: string;
  50741. /**
  50742. * Optional initial tab (default to DebugLayerTab.Properties)
  50743. */
  50744. initialTab?: DebugLayerTab;
  50745. }
  50746. interface Scene {
  50747. /**
  50748. * @hidden
  50749. * Backing field
  50750. */
  50751. _debugLayer: DebugLayer;
  50752. /**
  50753. * Gets the debug layer (aka Inspector) associated with the scene
  50754. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50755. */
  50756. debugLayer: DebugLayer;
  50757. }
  50758. /**
  50759. * Enum of inspector action tab
  50760. */
  50761. export enum DebugLayerTab {
  50762. /**
  50763. * Properties tag (default)
  50764. */
  50765. Properties = 0,
  50766. /**
  50767. * Debug tab
  50768. */
  50769. Debug = 1,
  50770. /**
  50771. * Statistics tab
  50772. */
  50773. Statistics = 2,
  50774. /**
  50775. * Tools tab
  50776. */
  50777. Tools = 3,
  50778. /**
  50779. * Settings tab
  50780. */
  50781. Settings = 4
  50782. }
  50783. /**
  50784. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50785. * what is happening in your scene
  50786. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50787. */
  50788. export class DebugLayer {
  50789. /**
  50790. * Define the url to get the inspector script from.
  50791. * By default it uses the babylonjs CDN.
  50792. * @ignoreNaming
  50793. */
  50794. static InspectorURL: string;
  50795. private _scene;
  50796. private BJSINSPECTOR;
  50797. private _onPropertyChangedObservable?;
  50798. /**
  50799. * Observable triggered when a property is changed through the inspector.
  50800. */
  50801. get onPropertyChangedObservable(): any;
  50802. /**
  50803. * Instantiates a new debug layer.
  50804. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50805. * what is happening in your scene
  50806. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50807. * @param scene Defines the scene to inspect
  50808. */
  50809. constructor(scene: Scene);
  50810. /** Creates the inspector window. */
  50811. private _createInspector;
  50812. /**
  50813. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50814. * @param entity defines the entity to select
  50815. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50816. */
  50817. select(entity: any, lineContainerTitles?: string | string[]): void;
  50818. /** Get the inspector from bundle or global */
  50819. private _getGlobalInspector;
  50820. /**
  50821. * Get if the inspector is visible or not.
  50822. * @returns true if visible otherwise, false
  50823. */
  50824. isVisible(): boolean;
  50825. /**
  50826. * Hide the inspector and close its window.
  50827. */
  50828. hide(): void;
  50829. /**
  50830. * Update the scene in the inspector
  50831. */
  50832. setAsActiveScene(): void;
  50833. /**
  50834. * Launch the debugLayer.
  50835. * @param config Define the configuration of the inspector
  50836. * @return a promise fulfilled when the debug layer is visible
  50837. */
  50838. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50839. }
  50840. }
  50841. declare module BABYLON {
  50842. /**
  50843. * Class containing static functions to help procedurally build meshes
  50844. */
  50845. export class BoxBuilder {
  50846. /**
  50847. * Creates a box mesh
  50848. * * The parameter `size` sets the size (float) of each box side (default 1)
  50849. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50850. * * 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)
  50851. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50853. * * 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
  50854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50855. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50856. * @param name defines the name of the mesh
  50857. * @param options defines the options used to create the mesh
  50858. * @param scene defines the hosting scene
  50859. * @returns the box mesh
  50860. */
  50861. static CreateBox(name: string, options: {
  50862. size?: number;
  50863. width?: number;
  50864. height?: number;
  50865. depth?: number;
  50866. faceUV?: Vector4[];
  50867. faceColors?: Color4[];
  50868. sideOrientation?: number;
  50869. frontUVs?: Vector4;
  50870. backUVs?: Vector4;
  50871. wrap?: boolean;
  50872. topBaseAt?: number;
  50873. bottomBaseAt?: number;
  50874. updatable?: boolean;
  50875. }, scene?: Nullable<Scene>): Mesh;
  50876. }
  50877. }
  50878. declare module BABYLON.Debug {
  50879. /**
  50880. * Used to show the physics impostor around the specific mesh
  50881. */
  50882. export class PhysicsViewer {
  50883. /** @hidden */
  50884. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50885. /** @hidden */
  50886. protected _meshes: Array<Nullable<AbstractMesh>>;
  50887. /** @hidden */
  50888. protected _scene: Nullable<Scene>;
  50889. /** @hidden */
  50890. protected _numMeshes: number;
  50891. /** @hidden */
  50892. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50893. private _renderFunction;
  50894. private _utilityLayer;
  50895. private _debugBoxMesh;
  50896. private _debugSphereMesh;
  50897. private _debugCylinderMesh;
  50898. private _debugMaterial;
  50899. private _debugMeshMeshes;
  50900. /**
  50901. * Creates a new PhysicsViewer
  50902. * @param scene defines the hosting scene
  50903. */
  50904. constructor(scene: Scene);
  50905. /** @hidden */
  50906. protected _updateDebugMeshes(): void;
  50907. /**
  50908. * Renders a specified physic impostor
  50909. * @param impostor defines the impostor to render
  50910. * @param targetMesh defines the mesh represented by the impostor
  50911. * @returns the new debug mesh used to render the impostor
  50912. */
  50913. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50914. /**
  50915. * Hides a specified physic impostor
  50916. * @param impostor defines the impostor to hide
  50917. */
  50918. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50919. private _getDebugMaterial;
  50920. private _getDebugBoxMesh;
  50921. private _getDebugSphereMesh;
  50922. private _getDebugCylinderMesh;
  50923. private _getDebugMeshMesh;
  50924. private _getDebugMesh;
  50925. /** Releases all resources */
  50926. dispose(): void;
  50927. }
  50928. }
  50929. declare module BABYLON {
  50930. /**
  50931. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50932. * in order to better appreciate the issue one might have.
  50933. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50934. */
  50935. export class RayHelper {
  50936. /**
  50937. * Defines the ray we are currently tryin to visualize.
  50938. */
  50939. ray: Nullable<Ray>;
  50940. private _renderPoints;
  50941. private _renderLine;
  50942. private _renderFunction;
  50943. private _scene;
  50944. private _onAfterRenderObserver;
  50945. private _onAfterStepObserver;
  50946. private _attachedToMesh;
  50947. private _meshSpaceDirection;
  50948. private _meshSpaceOrigin;
  50949. /**
  50950. * Helper function to create a colored helper in a scene in one line.
  50951. * @param ray Defines the ray we are currently tryin to visualize
  50952. * @param scene Defines the scene the ray is used in
  50953. * @param color Defines the color we want to see the ray in
  50954. * @returns The newly created ray helper.
  50955. */
  50956. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50957. /**
  50958. * Instantiate a new ray helper.
  50959. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50960. * in order to better appreciate the issue one might have.
  50961. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50962. * @param ray Defines the ray we are currently tryin to visualize
  50963. */
  50964. constructor(ray: Ray);
  50965. /**
  50966. * Shows the ray we are willing to debug.
  50967. * @param scene Defines the scene the ray needs to be rendered in
  50968. * @param color Defines the color the ray needs to be rendered in
  50969. */
  50970. show(scene: Scene, color?: Color3): void;
  50971. /**
  50972. * Hides the ray we are debugging.
  50973. */
  50974. hide(): void;
  50975. private _render;
  50976. /**
  50977. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50978. * @param mesh Defines the mesh we want the helper attached to
  50979. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50980. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50981. * @param length Defines the length of the ray
  50982. */
  50983. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50984. /**
  50985. * Detach the ray helper from the mesh it has previously been attached to.
  50986. */
  50987. detachFromMesh(): void;
  50988. private _updateToMesh;
  50989. /**
  50990. * Dispose the helper and release its associated resources.
  50991. */
  50992. dispose(): void;
  50993. }
  50994. }
  50995. declare module BABYLON {
  50996. /**
  50997. * Defines the options associated with the creation of a SkeletonViewer.
  50998. */
  50999. export interface ISkeletonViewerOptions {
  51000. /** Should the system pause animations before building the Viewer? */
  51001. pauseAnimations: boolean;
  51002. /** Should the system return the skeleton to rest before building? */
  51003. returnToRest: boolean;
  51004. /** public Display Mode of the Viewer */
  51005. displayMode: number;
  51006. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51007. displayOptions: ISkeletonViewerDisplayOptions;
  51008. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51009. computeBonesUsingShaders: boolean;
  51010. /** Flag ignore non weighted bones */
  51011. useAllBones: boolean;
  51012. }
  51013. /**
  51014. * Defines how to display the various bone meshes for the viewer.
  51015. */
  51016. export interface ISkeletonViewerDisplayOptions {
  51017. /** How far down to start tapering the bone spurs */
  51018. midStep?: number;
  51019. /** How big is the midStep? */
  51020. midStepFactor?: number;
  51021. /** Base for the Sphere Size */
  51022. sphereBaseSize?: number;
  51023. /** The ratio of the sphere to the longest bone in units */
  51024. sphereScaleUnit?: number;
  51025. /** Ratio for the Sphere Size */
  51026. sphereFactor?: number;
  51027. }
  51028. /**
  51029. * Defines the constructor options for the BoneWeight Shader.
  51030. */
  51031. export interface IBoneWeightShaderOptions {
  51032. /** Skeleton to Map */
  51033. skeleton: Skeleton;
  51034. /** Colors for Uninfluenced bones */
  51035. colorBase?: Color3;
  51036. /** Colors for 0.0-0.25 Weight bones */
  51037. colorZero?: Color3;
  51038. /** Color for 0.25-0.5 Weight Influence */
  51039. colorQuarter?: Color3;
  51040. /** Color for 0.5-0.75 Weight Influence */
  51041. colorHalf?: Color3;
  51042. /** Color for 0.75-1 Weight Influence */
  51043. colorFull?: Color3;
  51044. /** Color for Zero Weight Influence */
  51045. targetBoneIndex?: number;
  51046. }
  51047. /**
  51048. * Simple structure of the gradient steps for the Color Map.
  51049. */
  51050. export interface ISkeletonMapShaderColorMapKnot {
  51051. /** Color of the Knot */
  51052. color: Color3;
  51053. /** Location of the Knot */
  51054. location: number;
  51055. }
  51056. /**
  51057. * Defines the constructor options for the SkeletonMap Shader.
  51058. */
  51059. export interface ISkeletonMapShaderOptions {
  51060. /** Skeleton to Map */
  51061. skeleton: Skeleton;
  51062. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51063. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51064. }
  51065. }
  51066. declare module BABYLON {
  51067. /**
  51068. * Class containing static functions to help procedurally build meshes
  51069. */
  51070. export class RibbonBuilder {
  51071. /**
  51072. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51073. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51074. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51075. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51076. * * 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
  51077. * * 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
  51078. * * 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
  51079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51080. * * 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
  51081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51082. * * 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
  51083. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51084. * * 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
  51085. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51087. * @param name defines the name of the mesh
  51088. * @param options defines the options used to create the mesh
  51089. * @param scene defines the hosting scene
  51090. * @returns the ribbon mesh
  51091. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51092. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51093. */
  51094. static CreateRibbon(name: string, options: {
  51095. pathArray: Vector3[][];
  51096. closeArray?: boolean;
  51097. closePath?: boolean;
  51098. offset?: number;
  51099. updatable?: boolean;
  51100. sideOrientation?: number;
  51101. frontUVs?: Vector4;
  51102. backUVs?: Vector4;
  51103. instance?: Mesh;
  51104. invertUV?: boolean;
  51105. uvs?: Vector2[];
  51106. colors?: Color4[];
  51107. }, scene?: Nullable<Scene>): Mesh;
  51108. }
  51109. }
  51110. declare module BABYLON {
  51111. /**
  51112. * Class containing static functions to help procedurally build meshes
  51113. */
  51114. export class ShapeBuilder {
  51115. /**
  51116. * 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.
  51117. * * 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.
  51118. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51119. * * 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.
  51120. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51121. * * 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
  51122. * * 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
  51123. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51125. * * 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
  51126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51128. * @param name defines the name of the mesh
  51129. * @param options defines the options used to create the mesh
  51130. * @param scene defines the hosting scene
  51131. * @returns the extruded shape mesh
  51132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51134. */
  51135. static ExtrudeShape(name: string, options: {
  51136. shape: Vector3[];
  51137. path: Vector3[];
  51138. scale?: number;
  51139. rotation?: number;
  51140. cap?: number;
  51141. updatable?: boolean;
  51142. sideOrientation?: number;
  51143. frontUVs?: Vector4;
  51144. backUVs?: Vector4;
  51145. instance?: Mesh;
  51146. invertUV?: boolean;
  51147. }, scene?: Nullable<Scene>): Mesh;
  51148. /**
  51149. * Creates an custom extruded shape mesh.
  51150. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51151. * * 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.
  51152. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51153. * * 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
  51154. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51155. * * 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
  51156. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51157. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51158. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51159. * * 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
  51160. * * 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
  51161. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51163. * * 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
  51164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51166. * @param name defines the name of the mesh
  51167. * @param options defines the options used to create the mesh
  51168. * @param scene defines the hosting scene
  51169. * @returns the custom extruded shape mesh
  51170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51173. */
  51174. static ExtrudeShapeCustom(name: string, options: {
  51175. shape: Vector3[];
  51176. path: Vector3[];
  51177. scaleFunction?: any;
  51178. rotationFunction?: any;
  51179. ribbonCloseArray?: boolean;
  51180. ribbonClosePath?: boolean;
  51181. cap?: number;
  51182. updatable?: boolean;
  51183. sideOrientation?: number;
  51184. frontUVs?: Vector4;
  51185. backUVs?: Vector4;
  51186. instance?: Mesh;
  51187. invertUV?: boolean;
  51188. }, scene?: Nullable<Scene>): Mesh;
  51189. private static _ExtrudeShapeGeneric;
  51190. }
  51191. }
  51192. declare module BABYLON.Debug {
  51193. /**
  51194. * Class used to render a debug view of a given skeleton
  51195. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51196. */
  51197. export class SkeletonViewer {
  51198. /** defines the skeleton to render */
  51199. skeleton: Skeleton;
  51200. /** defines the mesh attached to the skeleton */
  51201. mesh: AbstractMesh;
  51202. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51203. autoUpdateBonesMatrices: boolean;
  51204. /** defines the rendering group id to use with the viewer */
  51205. renderingGroupId: number;
  51206. /** is the options for the viewer */
  51207. options: Partial<ISkeletonViewerOptions>;
  51208. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51209. static readonly DISPLAY_LINES: number;
  51210. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51211. static readonly DISPLAY_SPHERES: number;
  51212. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51213. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51214. /** public static method to create a BoneWeight Shader
  51215. * @param options The constructor options
  51216. * @param scene The scene that the shader is scoped to
  51217. * @returns The created ShaderMaterial
  51218. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51219. */
  51220. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51221. /** public static method to create a BoneWeight Shader
  51222. * @param options The constructor options
  51223. * @param scene The scene that the shader is scoped to
  51224. * @returns The created ShaderMaterial
  51225. */
  51226. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51227. /** private static method to create a BoneWeight Shader
  51228. * @param size The size of the buffer to create (usually the bone count)
  51229. * @param colorMap The gradient data to generate
  51230. * @param scene The scene that the shader is scoped to
  51231. * @returns an Array of floats from the color gradient values
  51232. */
  51233. private static _CreateBoneMapColorBuffer;
  51234. /** If SkeletonViewer scene scope. */
  51235. private _scene;
  51236. /** Gets or sets the color used to render the skeleton */
  51237. color: Color3;
  51238. /** Array of the points of the skeleton fo the line view. */
  51239. private _debugLines;
  51240. /** The SkeletonViewers Mesh. */
  51241. private _debugMesh;
  51242. /** If SkeletonViewer is enabled. */
  51243. private _isEnabled;
  51244. /** If SkeletonViewer is ready. */
  51245. private _ready;
  51246. /** SkeletonViewer render observable. */
  51247. private _obs;
  51248. /** The Utility Layer to render the gizmos in. */
  51249. private _utilityLayer;
  51250. private _boneIndices;
  51251. /** Gets the Scene. */
  51252. get scene(): Scene;
  51253. /** Gets the utilityLayer. */
  51254. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51255. /** Checks Ready Status. */
  51256. get isReady(): Boolean;
  51257. /** Sets Ready Status. */
  51258. set ready(value: boolean);
  51259. /** Gets the debugMesh */
  51260. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51261. /** Sets the debugMesh */
  51262. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51263. /** Gets the material */
  51264. get material(): StandardMaterial;
  51265. /** Sets the material */
  51266. set material(value: StandardMaterial);
  51267. /** Gets the material */
  51268. get displayMode(): number;
  51269. /** Sets the material */
  51270. set displayMode(value: number);
  51271. /**
  51272. * Creates a new SkeletonViewer
  51273. * @param skeleton defines the skeleton to render
  51274. * @param mesh defines the mesh attached to the skeleton
  51275. * @param scene defines the hosting scene
  51276. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51277. * @param renderingGroupId defines the rendering group id to use with the viewer
  51278. * @param options All of the extra constructor options for the SkeletonViewer
  51279. */
  51280. constructor(
  51281. /** defines the skeleton to render */
  51282. skeleton: Skeleton,
  51283. /** defines the mesh attached to the skeleton */
  51284. mesh: AbstractMesh,
  51285. /** The Scene scope*/
  51286. scene: Scene,
  51287. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51288. autoUpdateBonesMatrices?: boolean,
  51289. /** defines the rendering group id to use with the viewer */
  51290. renderingGroupId?: number,
  51291. /** is the options for the viewer */
  51292. options?: Partial<ISkeletonViewerOptions>);
  51293. /** The Dynamic bindings for the update functions */
  51294. private _bindObs;
  51295. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51296. update(): void;
  51297. /** Gets or sets a boolean indicating if the viewer is enabled */
  51298. set isEnabled(value: boolean);
  51299. get isEnabled(): boolean;
  51300. private _getBonePosition;
  51301. private _getLinesForBonesWithLength;
  51302. private _getLinesForBonesNoLength;
  51303. /** function to revert the mesh and scene back to the initial state. */
  51304. private _revert;
  51305. /** function to build and bind sphere joint points and spur bone representations. */
  51306. private _buildSpheresAndSpurs;
  51307. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51308. private _displayLinesUpdate;
  51309. /** Changes the displayMode of the skeleton viewer
  51310. * @param mode The displayMode numerical value
  51311. */
  51312. changeDisplayMode(mode: number): void;
  51313. /** Changes the displayMode of the skeleton viewer
  51314. * @param option String of the option name
  51315. * @param value The numerical option value
  51316. */
  51317. changeDisplayOptions(option: string, value: number): void;
  51318. /** Release associated resources */
  51319. dispose(): void;
  51320. }
  51321. }
  51322. declare module BABYLON {
  51323. /**
  51324. * Enum for Device Types
  51325. */
  51326. export enum DeviceType {
  51327. /** Generic */
  51328. Generic = 0,
  51329. /** Keyboard */
  51330. Keyboard = 1,
  51331. /** Mouse */
  51332. Mouse = 2,
  51333. /** Touch Pointers */
  51334. Touch = 3,
  51335. /** PS4 Dual Shock */
  51336. DualShock = 4,
  51337. /** Xbox */
  51338. Xbox = 5,
  51339. /** Switch Controller */
  51340. Switch = 6
  51341. }
  51342. /**
  51343. * Enum for All Pointers (Touch/Mouse)
  51344. */
  51345. export enum PointerInput {
  51346. /** Horizontal Axis */
  51347. Horizontal = 0,
  51348. /** Vertical Axis */
  51349. Vertical = 1,
  51350. /** Left Click or Touch */
  51351. LeftClick = 2,
  51352. /** Middle Click */
  51353. MiddleClick = 3,
  51354. /** Right Click */
  51355. RightClick = 4,
  51356. /** Browser Back */
  51357. BrowserBack = 5,
  51358. /** Browser Forward */
  51359. BrowserForward = 6
  51360. }
  51361. /**
  51362. * Enum for Dual Shock Gamepad
  51363. */
  51364. export enum DualShockInput {
  51365. /** Cross */
  51366. Cross = 0,
  51367. /** Circle */
  51368. Circle = 1,
  51369. /** Square */
  51370. Square = 2,
  51371. /** Triangle */
  51372. Triangle = 3,
  51373. /** L1 */
  51374. L1 = 4,
  51375. /** R1 */
  51376. R1 = 5,
  51377. /** L2 */
  51378. L2 = 6,
  51379. /** R2 */
  51380. R2 = 7,
  51381. /** Share */
  51382. Share = 8,
  51383. /** Options */
  51384. Options = 9,
  51385. /** L3 */
  51386. L3 = 10,
  51387. /** R3 */
  51388. R3 = 11,
  51389. /** DPadUp */
  51390. DPadUp = 12,
  51391. /** DPadDown */
  51392. DPadDown = 13,
  51393. /** DPadLeft */
  51394. DPadLeft = 14,
  51395. /** DRight */
  51396. DPadRight = 15,
  51397. /** Home */
  51398. Home = 16,
  51399. /** TouchPad */
  51400. TouchPad = 17,
  51401. /** LStickXAxis */
  51402. LStickXAxis = 18,
  51403. /** LStickYAxis */
  51404. LStickYAxis = 19,
  51405. /** RStickXAxis */
  51406. RStickXAxis = 20,
  51407. /** RStickYAxis */
  51408. RStickYAxis = 21
  51409. }
  51410. /**
  51411. * Enum for Xbox Gamepad
  51412. */
  51413. export enum XboxInput {
  51414. /** A */
  51415. A = 0,
  51416. /** B */
  51417. B = 1,
  51418. /** X */
  51419. X = 2,
  51420. /** Y */
  51421. Y = 3,
  51422. /** LB */
  51423. LB = 4,
  51424. /** RB */
  51425. RB = 5,
  51426. /** LT */
  51427. LT = 6,
  51428. /** RT */
  51429. RT = 7,
  51430. /** Back */
  51431. Back = 8,
  51432. /** Start */
  51433. Start = 9,
  51434. /** LS */
  51435. LS = 10,
  51436. /** RS */
  51437. RS = 11,
  51438. /** DPadUp */
  51439. DPadUp = 12,
  51440. /** DPadDown */
  51441. DPadDown = 13,
  51442. /** DPadLeft */
  51443. DPadLeft = 14,
  51444. /** DRight */
  51445. DPadRight = 15,
  51446. /** Home */
  51447. Home = 16,
  51448. /** LStickXAxis */
  51449. LStickXAxis = 17,
  51450. /** LStickYAxis */
  51451. LStickYAxis = 18,
  51452. /** RStickXAxis */
  51453. RStickXAxis = 19,
  51454. /** RStickYAxis */
  51455. RStickYAxis = 20
  51456. }
  51457. /**
  51458. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51459. */
  51460. export enum SwitchInput {
  51461. /** B */
  51462. B = 0,
  51463. /** A */
  51464. A = 1,
  51465. /** Y */
  51466. Y = 2,
  51467. /** X */
  51468. X = 3,
  51469. /** L */
  51470. L = 4,
  51471. /** R */
  51472. R = 5,
  51473. /** ZL */
  51474. ZL = 6,
  51475. /** ZR */
  51476. ZR = 7,
  51477. /** Minus */
  51478. Minus = 8,
  51479. /** Plus */
  51480. Plus = 9,
  51481. /** LS */
  51482. LS = 10,
  51483. /** RS */
  51484. RS = 11,
  51485. /** DPadUp */
  51486. DPadUp = 12,
  51487. /** DPadDown */
  51488. DPadDown = 13,
  51489. /** DPadLeft */
  51490. DPadLeft = 14,
  51491. /** DRight */
  51492. DPadRight = 15,
  51493. /** Home */
  51494. Home = 16,
  51495. /** Capture */
  51496. Capture = 17,
  51497. /** LStickXAxis */
  51498. LStickXAxis = 18,
  51499. /** LStickYAxis */
  51500. LStickYAxis = 19,
  51501. /** RStickXAxis */
  51502. RStickXAxis = 20,
  51503. /** RStickYAxis */
  51504. RStickYAxis = 21
  51505. }
  51506. }
  51507. declare module BABYLON {
  51508. /**
  51509. * This class will take all inputs from Keyboard, Pointer, and
  51510. * any Gamepads and provide a polling system that all devices
  51511. * will use. This class assumes that there will only be one
  51512. * pointer device and one keyboard.
  51513. */
  51514. export class DeviceInputSystem implements IDisposable {
  51515. /**
  51516. * Callback to be triggered when a device is connected
  51517. */
  51518. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51519. /**
  51520. * Callback to be triggered when a device is disconnected
  51521. */
  51522. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51523. /**
  51524. * Callback to be triggered when event driven input is updated
  51525. */
  51526. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51527. private _inputs;
  51528. private _gamepads;
  51529. private _keyboardActive;
  51530. private _pointerActive;
  51531. private _elementToAttachTo;
  51532. private _keyboardDownEvent;
  51533. private _keyboardUpEvent;
  51534. private _pointerMoveEvent;
  51535. private _pointerDownEvent;
  51536. private _pointerUpEvent;
  51537. private _gamepadConnectedEvent;
  51538. private _gamepadDisconnectedEvent;
  51539. private static _MAX_KEYCODES;
  51540. private static _MAX_POINTER_INPUTS;
  51541. private constructor();
  51542. /**
  51543. * Creates a new DeviceInputSystem instance
  51544. * @param engine Engine to pull input element from
  51545. * @returns The new instance
  51546. */
  51547. static Create(engine: Engine): DeviceInputSystem;
  51548. /**
  51549. * Checks for current device input value, given an id and input index
  51550. * @param deviceName Id of connected device
  51551. * @param inputIndex Index of device input
  51552. * @returns Current value of input
  51553. */
  51554. /**
  51555. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51556. * @param deviceType Enum specifiying device type
  51557. * @param deviceSlot "Slot" or index that device is referenced in
  51558. * @param inputIndex Id of input to be checked
  51559. * @returns Current value of input
  51560. */
  51561. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51562. /**
  51563. * Dispose of all the eventlisteners
  51564. */
  51565. dispose(): void;
  51566. /**
  51567. * Add device and inputs to device array
  51568. * @param deviceType Enum specifiying device type
  51569. * @param deviceSlot "Slot" or index that device is referenced in
  51570. * @param numberOfInputs Number of input entries to create for given device
  51571. */
  51572. private _registerDevice;
  51573. /**
  51574. * Given a specific device name, remove that device from the device map
  51575. * @param deviceType Enum specifiying device type
  51576. * @param deviceSlot "Slot" or index that device is referenced in
  51577. */
  51578. private _unregisterDevice;
  51579. /**
  51580. * Handle all actions that come from keyboard interaction
  51581. */
  51582. private _handleKeyActions;
  51583. /**
  51584. * Handle all actions that come from pointer interaction
  51585. */
  51586. private _handlePointerActions;
  51587. /**
  51588. * Handle all actions that come from gamepad interaction
  51589. */
  51590. private _handleGamepadActions;
  51591. /**
  51592. * Update all non-event based devices with each frame
  51593. * @param deviceType Enum specifiying device type
  51594. * @param deviceSlot "Slot" or index that device is referenced in
  51595. * @param inputIndex Id of input to be checked
  51596. */
  51597. private _updateDevice;
  51598. /**
  51599. * Gets DeviceType from the device name
  51600. * @param deviceName Name of Device from DeviceInputSystem
  51601. * @returns DeviceType enum value
  51602. */
  51603. private _getGamepadDeviceType;
  51604. }
  51605. }
  51606. declare module BABYLON {
  51607. /**
  51608. * Type to handle enforcement of inputs
  51609. */
  51610. 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;
  51611. }
  51612. declare module BABYLON {
  51613. /**
  51614. * Class that handles all input for a specific device
  51615. */
  51616. export class DeviceSource<T extends DeviceType> {
  51617. /** Type of device */
  51618. readonly deviceType: DeviceType;
  51619. /** "Slot" or index that device is referenced in */
  51620. readonly deviceSlot: number;
  51621. /**
  51622. * Observable to handle device input changes per device
  51623. */
  51624. readonly onInputChangedObservable: Observable<{
  51625. inputIndex: DeviceInput<T>;
  51626. previousState: Nullable<number>;
  51627. currentState: Nullable<number>;
  51628. }>;
  51629. private readonly _deviceInputSystem;
  51630. /**
  51631. * Default Constructor
  51632. * @param deviceInputSystem Reference to DeviceInputSystem
  51633. * @param deviceType Type of device
  51634. * @param deviceSlot "Slot" or index that device is referenced in
  51635. */
  51636. constructor(deviceInputSystem: DeviceInputSystem,
  51637. /** Type of device */
  51638. deviceType: DeviceType,
  51639. /** "Slot" or index that device is referenced in */
  51640. deviceSlot?: number);
  51641. /**
  51642. * Get input for specific input
  51643. * @param inputIndex index of specific input on device
  51644. * @returns Input value from DeviceInputSystem
  51645. */
  51646. getInput(inputIndex: DeviceInput<T>): number;
  51647. }
  51648. /**
  51649. * Class to keep track of devices
  51650. */
  51651. export class DeviceSourceManager implements IDisposable {
  51652. /**
  51653. * Observable to be triggered when before a device is connected
  51654. */
  51655. readonly onBeforeDeviceConnectedObservable: Observable<{
  51656. deviceType: DeviceType;
  51657. deviceSlot: number;
  51658. }>;
  51659. /**
  51660. * Observable to be triggered when before a device is disconnected
  51661. */
  51662. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51663. deviceType: DeviceType;
  51664. deviceSlot: number;
  51665. }>;
  51666. /**
  51667. * Observable to be triggered when after a device is connected
  51668. */
  51669. readonly onAfterDeviceConnectedObservable: Observable<{
  51670. deviceType: DeviceType;
  51671. deviceSlot: number;
  51672. }>;
  51673. /**
  51674. * Observable to be triggered when after a device is disconnected
  51675. */
  51676. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51677. deviceType: DeviceType;
  51678. deviceSlot: number;
  51679. }>;
  51680. private readonly _devices;
  51681. private readonly _firstDevice;
  51682. private readonly _deviceInputSystem;
  51683. /**
  51684. * Default Constructor
  51685. * @param engine engine to pull input element from
  51686. */
  51687. constructor(engine: Engine);
  51688. /**
  51689. * Gets a DeviceSource, given a type and slot
  51690. * @param deviceType Enum specifying device type
  51691. * @param deviceSlot "Slot" or index that device is referenced in
  51692. * @returns DeviceSource object
  51693. */
  51694. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51695. /**
  51696. * Gets an array of DeviceSource objects for a given device type
  51697. * @param deviceType Enum specifying device type
  51698. * @returns Array of DeviceSource objects
  51699. */
  51700. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51701. /**
  51702. * Dispose of DeviceInputSystem and other parts
  51703. */
  51704. dispose(): void;
  51705. /**
  51706. * Function to add device name to device list
  51707. * @param deviceType Enum specifying device type
  51708. * @param deviceSlot "Slot" or index that device is referenced in
  51709. */
  51710. private _addDevice;
  51711. /**
  51712. * Function to remove device name to device list
  51713. * @param deviceType Enum specifying device type
  51714. * @param deviceSlot "Slot" or index that device is referenced in
  51715. */
  51716. private _removeDevice;
  51717. /**
  51718. * Updates array storing first connected device of each type
  51719. * @param type Type of Device
  51720. */
  51721. private _updateFirstDevices;
  51722. }
  51723. }
  51724. declare module BABYLON {
  51725. /**
  51726. * Options to create the null engine
  51727. */
  51728. export class NullEngineOptions {
  51729. /**
  51730. * Render width (Default: 512)
  51731. */
  51732. renderWidth: number;
  51733. /**
  51734. * Render height (Default: 256)
  51735. */
  51736. renderHeight: number;
  51737. /**
  51738. * Texture size (Default: 512)
  51739. */
  51740. textureSize: number;
  51741. /**
  51742. * If delta time between frames should be constant
  51743. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51744. */
  51745. deterministicLockstep: boolean;
  51746. /**
  51747. * Maximum about of steps between frames (Default: 4)
  51748. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51749. */
  51750. lockstepMaxSteps: number;
  51751. /**
  51752. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51753. */
  51754. useHighPrecisionMatrix?: boolean;
  51755. }
  51756. /**
  51757. * The null engine class provides support for headless version of babylon.js.
  51758. * This can be used in server side scenario or for testing purposes
  51759. */
  51760. export class NullEngine extends Engine {
  51761. private _options;
  51762. /**
  51763. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51764. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51765. * @returns true if engine is in deterministic lock step mode
  51766. */
  51767. isDeterministicLockStep(): boolean;
  51768. /**
  51769. * Gets the max steps when engine is running in deterministic lock step
  51770. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51771. * @returns the max steps
  51772. */
  51773. getLockstepMaxSteps(): number;
  51774. /**
  51775. * Gets the current hardware scaling level.
  51776. * By default the hardware scaling level is computed from the window device ratio.
  51777. * 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.
  51778. * @returns a number indicating the current hardware scaling level
  51779. */
  51780. getHardwareScalingLevel(): number;
  51781. constructor(options?: NullEngineOptions);
  51782. /**
  51783. * Creates a vertex buffer
  51784. * @param vertices the data for the vertex buffer
  51785. * @returns the new WebGL static buffer
  51786. */
  51787. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51788. /**
  51789. * Creates a new index buffer
  51790. * @param indices defines the content of the index buffer
  51791. * @param updatable defines if the index buffer must be updatable
  51792. * @returns a new webGL buffer
  51793. */
  51794. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51795. /**
  51796. * Clear the current render buffer or the current render target (if any is set up)
  51797. * @param color defines the color to use
  51798. * @param backBuffer defines if the back buffer must be cleared
  51799. * @param depth defines if the depth buffer must be cleared
  51800. * @param stencil defines if the stencil buffer must be cleared
  51801. */
  51802. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51803. /**
  51804. * Gets the current render width
  51805. * @param useScreen defines if screen size must be used (or the current render target if any)
  51806. * @returns a number defining the current render width
  51807. */
  51808. getRenderWidth(useScreen?: boolean): number;
  51809. /**
  51810. * Gets the current render height
  51811. * @param useScreen defines if screen size must be used (or the current render target if any)
  51812. * @returns a number defining the current render height
  51813. */
  51814. getRenderHeight(useScreen?: boolean): number;
  51815. /**
  51816. * Set the WebGL's viewport
  51817. * @param viewport defines the viewport element to be used
  51818. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51819. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51820. */
  51821. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51822. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51823. /**
  51824. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51825. * @param pipelineContext defines the pipeline context to use
  51826. * @param uniformsNames defines the list of uniform names
  51827. * @returns an array of webGL uniform locations
  51828. */
  51829. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51830. /**
  51831. * Gets the lsit of active attributes for a given webGL program
  51832. * @param pipelineContext defines the pipeline context to use
  51833. * @param attributesNames defines the list of attribute names to get
  51834. * @returns an array of indices indicating the offset of each attribute
  51835. */
  51836. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51837. /**
  51838. * Binds an effect to the webGL context
  51839. * @param effect defines the effect to bind
  51840. */
  51841. bindSamplers(effect: Effect): void;
  51842. /**
  51843. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51844. * @param effect defines the effect to activate
  51845. */
  51846. enableEffect(effect: Effect): void;
  51847. /**
  51848. * Set various states to the webGL context
  51849. * @param culling defines backface culling state
  51850. * @param zOffset defines the value to apply to zOffset (0 by default)
  51851. * @param force defines if states must be applied even if cache is up to date
  51852. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51853. */
  51854. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51855. /**
  51856. * Set the value of an uniform to an array of int32
  51857. * @param uniform defines the webGL uniform location where to store the value
  51858. * @param array defines the array of int32 to store
  51859. */
  51860. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51861. /**
  51862. * Set the value of an uniform to an array of int32 (stored as vec2)
  51863. * @param uniform defines the webGL uniform location where to store the value
  51864. * @param array defines the array of int32 to store
  51865. */
  51866. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51867. /**
  51868. * Set the value of an uniform to an array of int32 (stored as vec3)
  51869. * @param uniform defines the webGL uniform location where to store the value
  51870. * @param array defines the array of int32 to store
  51871. */
  51872. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51873. /**
  51874. * Set the value of an uniform to an array of int32 (stored as vec4)
  51875. * @param uniform defines the webGL uniform location where to store the value
  51876. * @param array defines the array of int32 to store
  51877. */
  51878. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51879. /**
  51880. * Set the value of an uniform to an array of float32
  51881. * @param uniform defines the webGL uniform location where to store the value
  51882. * @param array defines the array of float32 to store
  51883. */
  51884. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51885. /**
  51886. * Set the value of an uniform to an array of float32 (stored as vec2)
  51887. * @param uniform defines the webGL uniform location where to store the value
  51888. * @param array defines the array of float32 to store
  51889. */
  51890. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51891. /**
  51892. * Set the value of an uniform to an array of float32 (stored as vec3)
  51893. * @param uniform defines the webGL uniform location where to store the value
  51894. * @param array defines the array of float32 to store
  51895. */
  51896. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51897. /**
  51898. * Set the value of an uniform to an array of float32 (stored as vec4)
  51899. * @param uniform defines the webGL uniform location where to store the value
  51900. * @param array defines the array of float32 to store
  51901. */
  51902. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51903. /**
  51904. * Set the value of an uniform to an array of number
  51905. * @param uniform defines the webGL uniform location where to store the value
  51906. * @param array defines the array of number to store
  51907. */
  51908. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51909. /**
  51910. * Set the value of an uniform to an array of number (stored as vec2)
  51911. * @param uniform defines the webGL uniform location where to store the value
  51912. * @param array defines the array of number to store
  51913. */
  51914. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51915. /**
  51916. * Set the value of an uniform to an array of number (stored as vec3)
  51917. * @param uniform defines the webGL uniform location where to store the value
  51918. * @param array defines the array of number to store
  51919. */
  51920. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51921. /**
  51922. * Set the value of an uniform to an array of number (stored as vec4)
  51923. * @param uniform defines the webGL uniform location where to store the value
  51924. * @param array defines the array of number to store
  51925. */
  51926. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51927. /**
  51928. * Set the value of an uniform to an array of float32 (stored as matrices)
  51929. * @param uniform defines the webGL uniform location where to store the value
  51930. * @param matrices defines the array of float32 to store
  51931. */
  51932. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51933. /**
  51934. * Set the value of an uniform to a matrix (3x3)
  51935. * @param uniform defines the webGL uniform location where to store the value
  51936. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51937. */
  51938. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51939. /**
  51940. * Set the value of an uniform to a matrix (2x2)
  51941. * @param uniform defines the webGL uniform location where to store the value
  51942. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51943. */
  51944. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51945. /**
  51946. * Set the value of an uniform to a number (float)
  51947. * @param uniform defines the webGL uniform location where to store the value
  51948. * @param value defines the float number to store
  51949. */
  51950. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51951. /**
  51952. * Set the value of an uniform to a vec2
  51953. * @param uniform defines the webGL uniform location where to store the value
  51954. * @param x defines the 1st component of the value
  51955. * @param y defines the 2nd component of the value
  51956. */
  51957. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51958. /**
  51959. * Set the value of an uniform to a vec3
  51960. * @param uniform defines the webGL uniform location where to store the value
  51961. * @param x defines the 1st component of the value
  51962. * @param y defines the 2nd component of the value
  51963. * @param z defines the 3rd component of the value
  51964. */
  51965. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51966. /**
  51967. * Set the value of an uniform to a boolean
  51968. * @param uniform defines the webGL uniform location where to store the value
  51969. * @param bool defines the boolean to store
  51970. */
  51971. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51972. /**
  51973. * Set the value of an uniform to a vec4
  51974. * @param uniform defines the webGL uniform location where to store the value
  51975. * @param x defines the 1st component of the value
  51976. * @param y defines the 2nd component of the value
  51977. * @param z defines the 3rd component of the value
  51978. * @param w defines the 4th component of the value
  51979. */
  51980. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51981. /**
  51982. * Sets the current alpha mode
  51983. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51984. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51985. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51986. */
  51987. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51988. /**
  51989. * Bind webGl buffers directly to the webGL context
  51990. * @param vertexBuffers defines the vertex buffer to bind
  51991. * @param indexBuffer defines the index buffer to bind
  51992. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51993. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51994. * @param effect defines the effect associated with the vertex buffer
  51995. */
  51996. bindBuffers(vertexBuffers: {
  51997. [key: string]: VertexBuffer;
  51998. }, indexBuffer: DataBuffer, effect: Effect): void;
  51999. /**
  52000. * Force the entire cache to be cleared
  52001. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52002. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52003. */
  52004. wipeCaches(bruteForce?: boolean): void;
  52005. /**
  52006. * Send a draw order
  52007. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52008. * @param indexStart defines the starting index
  52009. * @param indexCount defines the number of index to draw
  52010. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52011. */
  52012. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52013. /**
  52014. * Draw a list of indexed primitives
  52015. * @param fillMode defines the primitive to use
  52016. * @param indexStart defines the starting index
  52017. * @param indexCount defines the number of index to draw
  52018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52019. */
  52020. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52021. /**
  52022. * Draw a list of unindexed primitives
  52023. * @param fillMode defines the primitive to use
  52024. * @param verticesStart defines the index of first vertex to draw
  52025. * @param verticesCount defines the count of vertices to draw
  52026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52027. */
  52028. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52029. /** @hidden */
  52030. _createTexture(): WebGLTexture;
  52031. /** @hidden */
  52032. _releaseTexture(texture: InternalTexture): void;
  52033. /**
  52034. * Usually called from Texture.ts.
  52035. * Passed information to create a WebGLTexture
  52036. * @param urlArg defines a value which contains one of the following:
  52037. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52038. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52039. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52040. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52041. * @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)
  52042. * @param scene needed for loading to the correct scene
  52043. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52044. * @param onLoad optional callback to be called upon successful completion
  52045. * @param onError optional callback to be called upon failure
  52046. * @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
  52047. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52048. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52049. * @param forcedExtension defines the extension to use to pick the right loader
  52050. * @param mimeType defines an optional mime type
  52051. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52052. */
  52053. 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;
  52054. /**
  52055. * Creates a new render target texture
  52056. * @param size defines the size of the texture
  52057. * @param options defines the options used to create the texture
  52058. * @returns a new render target texture stored in an InternalTexture
  52059. */
  52060. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52061. /**
  52062. * Update the sampling mode of a given texture
  52063. * @param samplingMode defines the required sampling mode
  52064. * @param texture defines the texture to update
  52065. */
  52066. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52067. /**
  52068. * Binds the frame buffer to the specified texture.
  52069. * @param texture The texture to render to or null for the default canvas
  52070. * @param faceIndex The face of the texture to render to in case of cube texture
  52071. * @param requiredWidth The width of the target to render to
  52072. * @param requiredHeight The height of the target to render to
  52073. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52074. * @param lodLevel defines le lod level to bind to the frame buffer
  52075. */
  52076. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52077. /**
  52078. * Unbind the current render target texture from the webGL context
  52079. * @param texture defines the render target texture to unbind
  52080. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52081. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52082. */
  52083. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52084. /**
  52085. * Creates a dynamic vertex buffer
  52086. * @param vertices the data for the dynamic vertex buffer
  52087. * @returns the new WebGL dynamic buffer
  52088. */
  52089. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52090. /**
  52091. * Update the content of a dynamic texture
  52092. * @param texture defines the texture to update
  52093. * @param canvas defines the canvas containing the source
  52094. * @param invertY defines if data must be stored with Y axis inverted
  52095. * @param premulAlpha defines if alpha is stored as premultiplied
  52096. * @param format defines the format of the data
  52097. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52098. */
  52099. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52100. /**
  52101. * Gets a boolean indicating if all created effects are ready
  52102. * @returns true if all effects are ready
  52103. */
  52104. areAllEffectsReady(): boolean;
  52105. /**
  52106. * @hidden
  52107. * Get the current error code of the webGL context
  52108. * @returns the error code
  52109. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52110. */
  52111. getError(): number;
  52112. /** @hidden */
  52113. _getUnpackAlignement(): number;
  52114. /** @hidden */
  52115. _unpackFlipY(value: boolean): void;
  52116. /**
  52117. * Update a dynamic index buffer
  52118. * @param indexBuffer defines the target index buffer
  52119. * @param indices defines the data to update
  52120. * @param offset defines the offset in the target index buffer where update should start
  52121. */
  52122. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52123. /**
  52124. * Updates a dynamic vertex buffer.
  52125. * @param vertexBuffer the vertex buffer to update
  52126. * @param vertices the data used to update the vertex buffer
  52127. * @param byteOffset the byte offset of the data (optional)
  52128. * @param byteLength the byte length of the data (optional)
  52129. */
  52130. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52131. /** @hidden */
  52132. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52133. /** @hidden */
  52134. _bindTexture(channel: number, texture: InternalTexture): void;
  52135. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52136. /**
  52137. * 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
  52138. */
  52139. releaseEffects(): void;
  52140. displayLoadingUI(): void;
  52141. hideLoadingUI(): void;
  52142. /** @hidden */
  52143. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52144. /** @hidden */
  52145. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52146. /** @hidden */
  52147. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52148. /** @hidden */
  52149. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52150. }
  52151. }
  52152. declare module BABYLON {
  52153. /**
  52154. * @hidden
  52155. **/
  52156. export class _TimeToken {
  52157. _startTimeQuery: Nullable<WebGLQuery>;
  52158. _endTimeQuery: Nullable<WebGLQuery>;
  52159. _timeElapsedQuery: Nullable<WebGLQuery>;
  52160. _timeElapsedQueryEnded: boolean;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. /** @hidden */
  52165. export class _OcclusionDataStorage {
  52166. /** @hidden */
  52167. occlusionInternalRetryCounter: number;
  52168. /** @hidden */
  52169. isOcclusionQueryInProgress: boolean;
  52170. /** @hidden */
  52171. isOccluded: boolean;
  52172. /** @hidden */
  52173. occlusionRetryCount: number;
  52174. /** @hidden */
  52175. occlusionType: number;
  52176. /** @hidden */
  52177. occlusionQueryAlgorithmType: number;
  52178. }
  52179. interface Engine {
  52180. /**
  52181. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52182. * @return the new query
  52183. */
  52184. createQuery(): WebGLQuery;
  52185. /**
  52186. * Delete and release a webGL query
  52187. * @param query defines the query to delete
  52188. * @return the current engine
  52189. */
  52190. deleteQuery(query: WebGLQuery): Engine;
  52191. /**
  52192. * Check if a given query has resolved and got its value
  52193. * @param query defines the query to check
  52194. * @returns true if the query got its value
  52195. */
  52196. isQueryResultAvailable(query: WebGLQuery): boolean;
  52197. /**
  52198. * Gets the value of a given query
  52199. * @param query defines the query to check
  52200. * @returns the value of the query
  52201. */
  52202. getQueryResult(query: WebGLQuery): number;
  52203. /**
  52204. * Initiates an occlusion query
  52205. * @param algorithmType defines the algorithm to use
  52206. * @param query defines the query to use
  52207. * @returns the current engine
  52208. * @see https://doc.babylonjs.com/features/occlusionquery
  52209. */
  52210. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52211. /**
  52212. * Ends an occlusion query
  52213. * @see https://doc.babylonjs.com/features/occlusionquery
  52214. * @param algorithmType defines the algorithm to use
  52215. * @returns the current engine
  52216. */
  52217. endOcclusionQuery(algorithmType: number): Engine;
  52218. /**
  52219. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52220. * Please note that only one query can be issued at a time
  52221. * @returns a time token used to track the time span
  52222. */
  52223. startTimeQuery(): Nullable<_TimeToken>;
  52224. /**
  52225. * Ends a time query
  52226. * @param token defines the token used to measure the time span
  52227. * @returns the time spent (in ns)
  52228. */
  52229. endTimeQuery(token: _TimeToken): int;
  52230. /** @hidden */
  52231. _currentNonTimestampToken: Nullable<_TimeToken>;
  52232. /** @hidden */
  52233. _createTimeQuery(): WebGLQuery;
  52234. /** @hidden */
  52235. _deleteTimeQuery(query: WebGLQuery): void;
  52236. /** @hidden */
  52237. _getGlAlgorithmType(algorithmType: number): number;
  52238. /** @hidden */
  52239. _getTimeQueryResult(query: WebGLQuery): any;
  52240. /** @hidden */
  52241. _getTimeQueryAvailability(query: WebGLQuery): any;
  52242. }
  52243. interface AbstractMesh {
  52244. /**
  52245. * Backing filed
  52246. * @hidden
  52247. */
  52248. __occlusionDataStorage: _OcclusionDataStorage;
  52249. /**
  52250. * Access property
  52251. * @hidden
  52252. */
  52253. _occlusionDataStorage: _OcclusionDataStorage;
  52254. /**
  52255. * 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.
  52256. * The default value is -1 which means don't break the query and wait till the result
  52257. * @see https://doc.babylonjs.com/features/occlusionquery
  52258. */
  52259. occlusionRetryCount: number;
  52260. /**
  52261. * 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:
  52262. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52263. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52264. * * 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.
  52265. * @see https://doc.babylonjs.com/features/occlusionquery
  52266. */
  52267. occlusionType: number;
  52268. /**
  52269. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52270. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52271. * * 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.
  52272. * @see https://doc.babylonjs.com/features/occlusionquery
  52273. */
  52274. occlusionQueryAlgorithmType: number;
  52275. /**
  52276. * 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
  52277. * @see https://doc.babylonjs.com/features/occlusionquery
  52278. */
  52279. isOccluded: boolean;
  52280. /**
  52281. * Flag to check the progress status of the query
  52282. * @see https://doc.babylonjs.com/features/occlusionquery
  52283. */
  52284. isOcclusionQueryInProgress: boolean;
  52285. }
  52286. }
  52287. declare module BABYLON {
  52288. /** @hidden */
  52289. export var _forceTransformFeedbackToBundle: boolean;
  52290. interface Engine {
  52291. /**
  52292. * Creates a webGL transform feedback object
  52293. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52294. * @returns the webGL transform feedback object
  52295. */
  52296. createTransformFeedback(): WebGLTransformFeedback;
  52297. /**
  52298. * Delete a webGL transform feedback object
  52299. * @param value defines the webGL transform feedback object to delete
  52300. */
  52301. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52302. /**
  52303. * Bind a webGL transform feedback object to the webgl context
  52304. * @param value defines the webGL transform feedback object to bind
  52305. */
  52306. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52307. /**
  52308. * Begins a transform feedback operation
  52309. * @param usePoints defines if points or triangles must be used
  52310. */
  52311. beginTransformFeedback(usePoints: boolean): void;
  52312. /**
  52313. * Ends a transform feedback operation
  52314. */
  52315. endTransformFeedback(): void;
  52316. /**
  52317. * Specify the varyings to use with transform feedback
  52318. * @param program defines the associated webGL program
  52319. * @param value defines the list of strings representing the varying names
  52320. */
  52321. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52322. /**
  52323. * Bind a webGL buffer for a transform feedback operation
  52324. * @param value defines the webGL buffer to bind
  52325. */
  52326. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52327. }
  52328. }
  52329. declare module BABYLON {
  52330. /**
  52331. * Class used to define an additional view for the engine
  52332. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52333. */
  52334. export class EngineView {
  52335. /** Defines the canvas where to render the view */
  52336. target: HTMLCanvasElement;
  52337. /** Defines an optional camera used to render the view (will use active camera else) */
  52338. camera?: Camera;
  52339. }
  52340. interface Engine {
  52341. /**
  52342. * Gets or sets the HTML element to use for attaching events
  52343. */
  52344. inputElement: Nullable<HTMLElement>;
  52345. /**
  52346. * Gets the current engine view
  52347. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52348. */
  52349. activeView: Nullable<EngineView>;
  52350. /** Gets or sets the list of views */
  52351. views: EngineView[];
  52352. /**
  52353. * Register a new child canvas
  52354. * @param canvas defines the canvas to register
  52355. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52356. * @returns the associated view
  52357. */
  52358. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52359. /**
  52360. * Remove a registered child canvas
  52361. * @param canvas defines the canvas to remove
  52362. * @returns the current engine
  52363. */
  52364. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52365. }
  52366. }
  52367. declare module BABYLON {
  52368. interface Engine {
  52369. /** @hidden */
  52370. _excludedCompressedTextures: string[];
  52371. /** @hidden */
  52372. _textureFormatInUse: string;
  52373. /**
  52374. * Gets the list of texture formats supported
  52375. */
  52376. readonly texturesSupported: Array<string>;
  52377. /**
  52378. * Gets the texture format in use
  52379. */
  52380. readonly textureFormatInUse: Nullable<string>;
  52381. /**
  52382. * Set the compressed texture extensions or file names to skip.
  52383. *
  52384. * @param skippedFiles defines the list of those texture files you want to skip
  52385. * Example: [".dds", ".env", "myfile.png"]
  52386. */
  52387. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52388. /**
  52389. * Set the compressed texture format to use, based on the formats you have, and the formats
  52390. * supported by the hardware / browser.
  52391. *
  52392. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52393. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52394. * to API arguments needed to compressed textures. This puts the burden on the container
  52395. * generator to house the arcane code for determining these for current & future formats.
  52396. *
  52397. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52398. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52399. *
  52400. * Note: The result of this call is not taken into account when a texture is base64.
  52401. *
  52402. * @param formatsAvailable defines the list of those format families you have created
  52403. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52404. *
  52405. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52406. * @returns The extension selected.
  52407. */
  52408. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52409. }
  52410. }
  52411. declare module BABYLON {
  52412. /**
  52413. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52414. */
  52415. export interface CubeMapInfo {
  52416. /**
  52417. * The pixel array for the front face.
  52418. * This is stored in format, left to right, up to down format.
  52419. */
  52420. front: Nullable<ArrayBufferView>;
  52421. /**
  52422. * The pixel array for the back face.
  52423. * This is stored in format, left to right, up to down format.
  52424. */
  52425. back: Nullable<ArrayBufferView>;
  52426. /**
  52427. * The pixel array for the left face.
  52428. * This is stored in format, left to right, up to down format.
  52429. */
  52430. left: Nullable<ArrayBufferView>;
  52431. /**
  52432. * The pixel array for the right face.
  52433. * This is stored in format, left to right, up to down format.
  52434. */
  52435. right: Nullable<ArrayBufferView>;
  52436. /**
  52437. * The pixel array for the up face.
  52438. * This is stored in format, left to right, up to down format.
  52439. */
  52440. up: Nullable<ArrayBufferView>;
  52441. /**
  52442. * The pixel array for the down face.
  52443. * This is stored in format, left to right, up to down format.
  52444. */
  52445. down: Nullable<ArrayBufferView>;
  52446. /**
  52447. * The size of the cubemap stored.
  52448. *
  52449. * Each faces will be size * size pixels.
  52450. */
  52451. size: number;
  52452. /**
  52453. * The format of the texture.
  52454. *
  52455. * RGBA, RGB.
  52456. */
  52457. format: number;
  52458. /**
  52459. * The type of the texture data.
  52460. *
  52461. * UNSIGNED_INT, FLOAT.
  52462. */
  52463. type: number;
  52464. /**
  52465. * Specifies whether the texture is in gamma space.
  52466. */
  52467. gammaSpace: boolean;
  52468. }
  52469. /**
  52470. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52471. */
  52472. export class PanoramaToCubeMapTools {
  52473. private static FACE_LEFT;
  52474. private static FACE_RIGHT;
  52475. private static FACE_FRONT;
  52476. private static FACE_BACK;
  52477. private static FACE_DOWN;
  52478. private static FACE_UP;
  52479. /**
  52480. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52481. *
  52482. * @param float32Array The source data.
  52483. * @param inputWidth The width of the input panorama.
  52484. * @param inputHeight The height of the input panorama.
  52485. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52486. * @return The cubemap data
  52487. */
  52488. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52489. private static CreateCubemapTexture;
  52490. private static CalcProjectionSpherical;
  52491. }
  52492. }
  52493. declare module BABYLON {
  52494. /**
  52495. * Helper class dealing with the extraction of spherical polynomial dataArray
  52496. * from a cube map.
  52497. */
  52498. export class CubeMapToSphericalPolynomialTools {
  52499. private static FileFaces;
  52500. /**
  52501. * Converts a texture to the according Spherical Polynomial data.
  52502. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52503. *
  52504. * @param texture The texture to extract the information from.
  52505. * @return The Spherical Polynomial data.
  52506. */
  52507. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52508. /**
  52509. * Converts a cubemap to the according Spherical Polynomial data.
  52510. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52511. *
  52512. * @param cubeInfo The Cube map to extract the information from.
  52513. * @return The Spherical Polynomial data.
  52514. */
  52515. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52516. }
  52517. }
  52518. declare module BABYLON {
  52519. interface BaseTexture {
  52520. /**
  52521. * Get the polynomial representation of the texture data.
  52522. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52523. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52524. */
  52525. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52526. }
  52527. }
  52528. declare module BABYLON {
  52529. /** @hidden */
  52530. export var rgbdEncodePixelShader: {
  52531. name: string;
  52532. shader: string;
  52533. };
  52534. }
  52535. declare module BABYLON {
  52536. /** @hidden */
  52537. export var rgbdDecodePixelShader: {
  52538. name: string;
  52539. shader: string;
  52540. };
  52541. }
  52542. declare module BABYLON {
  52543. /**
  52544. * Raw texture data and descriptor sufficient for WebGL texture upload
  52545. */
  52546. export interface EnvironmentTextureInfo {
  52547. /**
  52548. * Version of the environment map
  52549. */
  52550. version: number;
  52551. /**
  52552. * Width of image
  52553. */
  52554. width: number;
  52555. /**
  52556. * Irradiance information stored in the file.
  52557. */
  52558. irradiance: any;
  52559. /**
  52560. * Specular information stored in the file.
  52561. */
  52562. specular: any;
  52563. }
  52564. /**
  52565. * Defines One Image in the file. It requires only the position in the file
  52566. * as well as the length.
  52567. */
  52568. interface BufferImageData {
  52569. /**
  52570. * Length of the image data.
  52571. */
  52572. length: number;
  52573. /**
  52574. * Position of the data from the null terminator delimiting the end of the JSON.
  52575. */
  52576. position: number;
  52577. }
  52578. /**
  52579. * Defines the specular data enclosed in the file.
  52580. * This corresponds to the version 1 of the data.
  52581. */
  52582. export interface EnvironmentTextureSpecularInfoV1 {
  52583. /**
  52584. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52585. */
  52586. specularDataPosition?: number;
  52587. /**
  52588. * This contains all the images data needed to reconstruct the cubemap.
  52589. */
  52590. mipmaps: Array<BufferImageData>;
  52591. /**
  52592. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52593. */
  52594. lodGenerationScale: number;
  52595. }
  52596. /**
  52597. * Sets of helpers addressing the serialization and deserialization of environment texture
  52598. * stored in a BabylonJS env file.
  52599. * Those files are usually stored as .env files.
  52600. */
  52601. export class EnvironmentTextureTools {
  52602. /**
  52603. * Magic number identifying the env file.
  52604. */
  52605. private static _MagicBytes;
  52606. /**
  52607. * Gets the environment info from an env file.
  52608. * @param data The array buffer containing the .env bytes.
  52609. * @returns the environment file info (the json header) if successfully parsed.
  52610. */
  52611. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52612. /**
  52613. * Creates an environment texture from a loaded cube texture.
  52614. * @param texture defines the cube texture to convert in env file
  52615. * @return a promise containing the environment data if succesfull.
  52616. */
  52617. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52618. /**
  52619. * Creates a JSON representation of the spherical data.
  52620. * @param texture defines the texture containing the polynomials
  52621. * @return the JSON representation of the spherical info
  52622. */
  52623. private static _CreateEnvTextureIrradiance;
  52624. /**
  52625. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52626. * @param data the image data
  52627. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52628. * @return the views described by info providing access to the underlying buffer
  52629. */
  52630. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52631. /**
  52632. * Uploads the texture info contained in the env file to the GPU.
  52633. * @param texture defines the internal texture to upload to
  52634. * @param data defines the data to load
  52635. * @param info defines the texture info retrieved through the GetEnvInfo method
  52636. * @returns a promise
  52637. */
  52638. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52639. private static _OnImageReadyAsync;
  52640. /**
  52641. * Uploads the levels of image data to the GPU.
  52642. * @param texture defines the internal texture to upload to
  52643. * @param imageData defines the array buffer views of image data [mipmap][face]
  52644. * @returns a promise
  52645. */
  52646. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52647. /**
  52648. * Uploads spherical polynomials information to the texture.
  52649. * @param texture defines the texture we are trying to upload the information to
  52650. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52651. */
  52652. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52653. /** @hidden */
  52654. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52655. }
  52656. }
  52657. declare module BABYLON {
  52658. /**
  52659. * Class used to inline functions in shader code
  52660. */
  52661. export class ShaderCodeInliner {
  52662. private static readonly _RegexpFindFunctionNameAndType;
  52663. private _sourceCode;
  52664. private _functionDescr;
  52665. private _numMaxIterations;
  52666. /** Gets or sets the token used to mark the functions to inline */
  52667. inlineToken: string;
  52668. /** Gets or sets the debug mode */
  52669. debug: boolean;
  52670. /** Gets the code after the inlining process */
  52671. get code(): string;
  52672. /**
  52673. * Initializes the inliner
  52674. * @param sourceCode shader code source to inline
  52675. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52676. */
  52677. constructor(sourceCode: string, numMaxIterations?: number);
  52678. /**
  52679. * Start the processing of the shader code
  52680. */
  52681. processCode(): void;
  52682. private _collectFunctions;
  52683. private _processInlining;
  52684. private _extractBetweenMarkers;
  52685. private _skipWhitespaces;
  52686. private _removeComments;
  52687. private _replaceFunctionCallsByCode;
  52688. private _findBackward;
  52689. private _escapeRegExp;
  52690. private _replaceNames;
  52691. }
  52692. }
  52693. declare module BABYLON {
  52694. /**
  52695. * Container for accessors for natively-stored mesh data buffers.
  52696. */
  52697. class NativeDataBuffer extends DataBuffer {
  52698. /**
  52699. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52700. */
  52701. nativeIndexBuffer?: any;
  52702. /**
  52703. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52704. */
  52705. nativeVertexBuffer?: any;
  52706. }
  52707. /** @hidden */
  52708. class NativeTexture extends InternalTexture {
  52709. getInternalTexture(): InternalTexture;
  52710. getViewCount(): number;
  52711. }
  52712. /** @hidden */
  52713. export class NativeEngine extends Engine {
  52714. private readonly _native;
  52715. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52716. private readonly INVALID_HANDLE;
  52717. private _boundBuffersVertexArray;
  52718. getHardwareScalingLevel(): number;
  52719. constructor();
  52720. dispose(): void;
  52721. /**
  52722. * Can be used to override the current requestAnimationFrame requester.
  52723. * @hidden
  52724. */
  52725. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52726. /**
  52727. * Override default engine behavior.
  52728. * @param color
  52729. * @param backBuffer
  52730. * @param depth
  52731. * @param stencil
  52732. */
  52733. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52734. /**
  52735. * Gets host document
  52736. * @returns the host document object
  52737. */
  52738. getHostDocument(): Nullable<Document>;
  52739. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52740. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52741. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52742. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52743. [key: string]: VertexBuffer;
  52744. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52745. bindBuffers(vertexBuffers: {
  52746. [key: string]: VertexBuffer;
  52747. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52748. recordVertexArrayObject(vertexBuffers: {
  52749. [key: string]: VertexBuffer;
  52750. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52751. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52752. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52753. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52754. /**
  52755. * Draw a list of indexed primitives
  52756. * @param fillMode defines the primitive to use
  52757. * @param indexStart defines the starting index
  52758. * @param indexCount defines the number of index to draw
  52759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52760. */
  52761. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52762. /**
  52763. * Draw a list of unindexed primitives
  52764. * @param fillMode defines the primitive to use
  52765. * @param verticesStart defines the index of first vertex to draw
  52766. * @param verticesCount defines the count of vertices to draw
  52767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52768. */
  52769. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52770. createPipelineContext(): IPipelineContext;
  52771. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52772. /** @hidden */
  52773. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52774. /** @hidden */
  52775. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52776. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52777. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52778. protected _setProgram(program: WebGLProgram): void;
  52779. _releaseEffect(effect: Effect): void;
  52780. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52781. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52782. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52783. bindSamplers(effect: Effect): void;
  52784. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52785. getRenderWidth(useScreen?: boolean): number;
  52786. getRenderHeight(useScreen?: boolean): number;
  52787. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52788. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52789. /**
  52790. * Set the z offset to apply to current rendering
  52791. * @param value defines the offset to apply
  52792. */
  52793. setZOffset(value: number): void;
  52794. /**
  52795. * Gets the current value of the zOffset
  52796. * @returns the current zOffset state
  52797. */
  52798. getZOffset(): number;
  52799. /**
  52800. * Enable or disable depth buffering
  52801. * @param enable defines the state to set
  52802. */
  52803. setDepthBuffer(enable: boolean): void;
  52804. /**
  52805. * Gets a boolean indicating if depth writing is enabled
  52806. * @returns the current depth writing state
  52807. */
  52808. getDepthWrite(): boolean;
  52809. /**
  52810. * Enable or disable depth writing
  52811. * @param enable defines the state to set
  52812. */
  52813. setDepthWrite(enable: boolean): void;
  52814. /**
  52815. * Enable or disable color writing
  52816. * @param enable defines the state to set
  52817. */
  52818. setColorWrite(enable: boolean): void;
  52819. /**
  52820. * Gets a boolean indicating if color writing is enabled
  52821. * @returns the current color writing state
  52822. */
  52823. getColorWrite(): boolean;
  52824. /**
  52825. * Sets alpha constants used by some alpha blending modes
  52826. * @param r defines the red component
  52827. * @param g defines the green component
  52828. * @param b defines the blue component
  52829. * @param a defines the alpha component
  52830. */
  52831. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52832. /**
  52833. * Sets the current alpha mode
  52834. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52835. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52836. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52837. */
  52838. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52839. /**
  52840. * Gets the current alpha mode
  52841. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52842. * @returns the current alpha mode
  52843. */
  52844. getAlphaMode(): number;
  52845. setInt(uniform: WebGLUniformLocation, int: number): void;
  52846. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52847. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52848. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52849. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52850. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52851. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52852. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52853. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52854. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52855. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52856. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52857. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52858. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52859. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52860. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52861. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52862. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52863. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52864. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52865. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52866. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52867. wipeCaches(bruteForce?: boolean): void;
  52868. _createTexture(): WebGLTexture;
  52869. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52870. /**
  52871. * Usually called from Texture.ts.
  52872. * Passed information to create a WebGLTexture
  52873. * @param url defines a value which contains one of the following:
  52874. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52875. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52876. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52877. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52878. * @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)
  52879. * @param scene needed for loading to the correct scene
  52880. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52881. * @param onLoad optional callback to be called upon successful completion
  52882. * @param onError optional callback to be called upon failure
  52883. * @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
  52884. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52885. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52886. * @param forcedExtension defines the extension to use to pick the right loader
  52887. * @param mimeType defines an optional mime type
  52888. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52889. */
  52890. 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): InternalTexture;
  52891. /**
  52892. * Creates a cube texture
  52893. * @param rootUrl defines the url where the files to load is located
  52894. * @param scene defines the current scene
  52895. * @param files defines the list of files to load (1 per face)
  52896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52897. * @param onLoad defines an optional callback raised when the texture is loaded
  52898. * @param onError defines an optional callback raised if there is an issue to load the texture
  52899. * @param format defines the format of the data
  52900. * @param forcedExtension defines the extension to use to pick the right loader
  52901. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52902. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52903. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52904. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52905. * @returns the cube texture as an InternalTexture
  52906. */
  52907. 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;
  52908. private _getSamplingFilter;
  52909. private static _GetNativeTextureFormat;
  52910. createRenderTargetTexture(size: number | {
  52911. width: number;
  52912. height: number;
  52913. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52914. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52915. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52916. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52917. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52918. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52919. /**
  52920. * Updates a dynamic vertex buffer.
  52921. * @param vertexBuffer the vertex buffer to update
  52922. * @param data the data used to update the vertex buffer
  52923. * @param byteOffset the byte offset of the data (optional)
  52924. * @param byteLength the byte length of the data (optional)
  52925. */
  52926. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52927. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52928. private _updateAnisotropicLevel;
  52929. private _getAddressMode;
  52930. /** @hidden */
  52931. _bindTexture(channel: number, texture: InternalTexture): void;
  52932. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52933. releaseEffects(): void;
  52934. /** @hidden */
  52935. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52936. /** @hidden */
  52937. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52938. /** @hidden */
  52939. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52940. /** @hidden */
  52941. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52942. }
  52943. }
  52944. declare module BABYLON {
  52945. /**
  52946. * Gather the list of clipboard event types as constants.
  52947. */
  52948. export class ClipboardEventTypes {
  52949. /**
  52950. * The clipboard event is fired when a copy command is active (pressed).
  52951. */
  52952. static readonly COPY: number;
  52953. /**
  52954. * The clipboard event is fired when a cut command is active (pressed).
  52955. */
  52956. static readonly CUT: number;
  52957. /**
  52958. * The clipboard event is fired when a paste command is active (pressed).
  52959. */
  52960. static readonly PASTE: number;
  52961. }
  52962. /**
  52963. * This class is used to store clipboard related info for the onClipboardObservable event.
  52964. */
  52965. export class ClipboardInfo {
  52966. /**
  52967. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52968. */
  52969. type: number;
  52970. /**
  52971. * Defines the related dom event
  52972. */
  52973. event: ClipboardEvent;
  52974. /**
  52975. *Creates an instance of ClipboardInfo.
  52976. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52977. * @param event Defines the related dom event
  52978. */
  52979. constructor(
  52980. /**
  52981. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52982. */
  52983. type: number,
  52984. /**
  52985. * Defines the related dom event
  52986. */
  52987. event: ClipboardEvent);
  52988. /**
  52989. * Get the clipboard event's type from the keycode.
  52990. * @param keyCode Defines the keyCode for the current keyboard event.
  52991. * @return {number}
  52992. */
  52993. static GetTypeFromCharacter(keyCode: number): number;
  52994. }
  52995. }
  52996. declare module BABYLON {
  52997. /**
  52998. * Google Daydream controller
  52999. */
  53000. export class DaydreamController extends WebVRController {
  53001. /**
  53002. * Base Url for the controller model.
  53003. */
  53004. static MODEL_BASE_URL: string;
  53005. /**
  53006. * File name for the controller model.
  53007. */
  53008. static MODEL_FILENAME: string;
  53009. /**
  53010. * Gamepad Id prefix used to identify Daydream Controller.
  53011. */
  53012. static readonly GAMEPAD_ID_PREFIX: string;
  53013. /**
  53014. * Creates a new DaydreamController from a gamepad
  53015. * @param vrGamepad the gamepad that the controller should be created from
  53016. */
  53017. constructor(vrGamepad: any);
  53018. /**
  53019. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53020. * @param scene scene in which to add meshes
  53021. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53022. */
  53023. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53024. /**
  53025. * Called once for each button that changed state since the last frame
  53026. * @param buttonIdx Which button index changed
  53027. * @param state New state of the button
  53028. * @param changes Which properties on the state changed since last frame
  53029. */
  53030. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53031. }
  53032. }
  53033. declare module BABYLON {
  53034. /**
  53035. * Gear VR Controller
  53036. */
  53037. export class GearVRController extends WebVRController {
  53038. /**
  53039. * Base Url for the controller model.
  53040. */
  53041. static MODEL_BASE_URL: string;
  53042. /**
  53043. * File name for the controller model.
  53044. */
  53045. static MODEL_FILENAME: string;
  53046. /**
  53047. * Gamepad Id prefix used to identify this controller.
  53048. */
  53049. static readonly GAMEPAD_ID_PREFIX: string;
  53050. private readonly _buttonIndexToObservableNameMap;
  53051. /**
  53052. * Creates a new GearVRController from a gamepad
  53053. * @param vrGamepad the gamepad that the controller should be created from
  53054. */
  53055. constructor(vrGamepad: any);
  53056. /**
  53057. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53058. * @param scene scene in which to add meshes
  53059. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53060. */
  53061. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53062. /**
  53063. * Called once for each button that changed state since the last frame
  53064. * @param buttonIdx Which button index changed
  53065. * @param state New state of the button
  53066. * @param changes Which properties on the state changed since last frame
  53067. */
  53068. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53069. }
  53070. }
  53071. declare module BABYLON {
  53072. /**
  53073. * Generic Controller
  53074. */
  53075. export class GenericController extends WebVRController {
  53076. /**
  53077. * Base Url for the controller model.
  53078. */
  53079. static readonly MODEL_BASE_URL: string;
  53080. /**
  53081. * File name for the controller model.
  53082. */
  53083. static readonly MODEL_FILENAME: string;
  53084. /**
  53085. * Creates a new GenericController from a gamepad
  53086. * @param vrGamepad the gamepad that the controller should be created from
  53087. */
  53088. constructor(vrGamepad: any);
  53089. /**
  53090. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53091. * @param scene scene in which to add meshes
  53092. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53093. */
  53094. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53095. /**
  53096. * Called once for each button that changed state since the last frame
  53097. * @param buttonIdx Which button index changed
  53098. * @param state New state of the button
  53099. * @param changes Which properties on the state changed since last frame
  53100. */
  53101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53102. }
  53103. }
  53104. declare module BABYLON {
  53105. /**
  53106. * Oculus Touch Controller
  53107. */
  53108. export class OculusTouchController extends WebVRController {
  53109. /**
  53110. * Base Url for the controller model.
  53111. */
  53112. static MODEL_BASE_URL: string;
  53113. /**
  53114. * File name for the left controller model.
  53115. */
  53116. static MODEL_LEFT_FILENAME: string;
  53117. /**
  53118. * File name for the right controller model.
  53119. */
  53120. static MODEL_RIGHT_FILENAME: string;
  53121. /**
  53122. * Base Url for the Quest controller model.
  53123. */
  53124. static QUEST_MODEL_BASE_URL: string;
  53125. /**
  53126. * @hidden
  53127. * If the controllers are running on a device that needs the updated Quest controller models
  53128. */
  53129. static _IsQuest: boolean;
  53130. /**
  53131. * Fired when the secondary trigger on this controller is modified
  53132. */
  53133. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53134. /**
  53135. * Fired when the thumb rest on this controller is modified
  53136. */
  53137. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53138. /**
  53139. * Creates a new OculusTouchController from a gamepad
  53140. * @param vrGamepad the gamepad that the controller should be created from
  53141. */
  53142. constructor(vrGamepad: any);
  53143. /**
  53144. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53145. * @param scene scene in which to add meshes
  53146. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53147. */
  53148. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53149. /**
  53150. * Fired when the A button on this controller is modified
  53151. */
  53152. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53153. /**
  53154. * Fired when the B button on this controller is modified
  53155. */
  53156. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53157. /**
  53158. * Fired when the X button on this controller is modified
  53159. */
  53160. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53161. /**
  53162. * Fired when the Y button on this controller is modified
  53163. */
  53164. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53165. /**
  53166. * Called once for each button that changed state since the last frame
  53167. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53168. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53169. * 2) secondary trigger (same)
  53170. * 3) A (right) X (left), touch, pressed = value
  53171. * 4) B / Y
  53172. * 5) thumb rest
  53173. * @param buttonIdx Which button index changed
  53174. * @param state New state of the button
  53175. * @param changes Which properties on the state changed since last frame
  53176. */
  53177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53178. }
  53179. }
  53180. declare module BABYLON {
  53181. /**
  53182. * Vive Controller
  53183. */
  53184. export class ViveController extends WebVRController {
  53185. /**
  53186. * Base Url for the controller model.
  53187. */
  53188. static MODEL_BASE_URL: string;
  53189. /**
  53190. * File name for the controller model.
  53191. */
  53192. static MODEL_FILENAME: string;
  53193. /**
  53194. * Creates a new ViveController from a gamepad
  53195. * @param vrGamepad the gamepad that the controller should be created from
  53196. */
  53197. constructor(vrGamepad: any);
  53198. /**
  53199. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53200. * @param scene scene in which to add meshes
  53201. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53202. */
  53203. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53204. /**
  53205. * Fired when the left button on this controller is modified
  53206. */
  53207. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53208. /**
  53209. * Fired when the right button on this controller is modified
  53210. */
  53211. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53212. /**
  53213. * Fired when the menu button on this controller is modified
  53214. */
  53215. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53216. /**
  53217. * Called once for each button that changed state since the last frame
  53218. * Vive mapping:
  53219. * 0: touchpad
  53220. * 1: trigger
  53221. * 2: left AND right buttons
  53222. * 3: menu button
  53223. * @param buttonIdx Which button index changed
  53224. * @param state New state of the button
  53225. * @param changes Which properties on the state changed since last frame
  53226. */
  53227. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53228. }
  53229. }
  53230. declare module BABYLON {
  53231. /**
  53232. * Defines the WindowsMotionController object that the state of the windows motion controller
  53233. */
  53234. export class WindowsMotionController extends WebVRController {
  53235. /**
  53236. * The base url used to load the left and right controller models
  53237. */
  53238. static MODEL_BASE_URL: string;
  53239. /**
  53240. * The name of the left controller model file
  53241. */
  53242. static MODEL_LEFT_FILENAME: string;
  53243. /**
  53244. * The name of the right controller model file
  53245. */
  53246. static MODEL_RIGHT_FILENAME: string;
  53247. /**
  53248. * The controller name prefix for this controller type
  53249. */
  53250. static readonly GAMEPAD_ID_PREFIX: string;
  53251. /**
  53252. * The controller id pattern for this controller type
  53253. */
  53254. private static readonly GAMEPAD_ID_PATTERN;
  53255. private _loadedMeshInfo;
  53256. protected readonly _mapping: {
  53257. buttons: string[];
  53258. buttonMeshNames: {
  53259. trigger: string;
  53260. menu: string;
  53261. grip: string;
  53262. thumbstick: string;
  53263. trackpad: string;
  53264. };
  53265. buttonObservableNames: {
  53266. trigger: string;
  53267. menu: string;
  53268. grip: string;
  53269. thumbstick: string;
  53270. trackpad: string;
  53271. };
  53272. axisMeshNames: string[];
  53273. pointingPoseMeshName: string;
  53274. };
  53275. /**
  53276. * Fired when the trackpad on this controller is clicked
  53277. */
  53278. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53279. /**
  53280. * Fired when the trackpad on this controller is modified
  53281. */
  53282. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53283. /**
  53284. * The current x and y values of this controller's trackpad
  53285. */
  53286. trackpad: StickValues;
  53287. /**
  53288. * Creates a new WindowsMotionController from a gamepad
  53289. * @param vrGamepad the gamepad that the controller should be created from
  53290. */
  53291. constructor(vrGamepad: any);
  53292. /**
  53293. * Fired when the trigger on this controller is modified
  53294. */
  53295. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53296. /**
  53297. * Fired when the menu button on this controller is modified
  53298. */
  53299. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53300. /**
  53301. * Fired when the grip button on this controller is modified
  53302. */
  53303. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53304. /**
  53305. * Fired when the thumbstick button on this controller is modified
  53306. */
  53307. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53308. /**
  53309. * Fired when the touchpad button on this controller is modified
  53310. */
  53311. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53312. /**
  53313. * Fired when the touchpad values on this controller are modified
  53314. */
  53315. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53316. protected _updateTrackpad(): void;
  53317. /**
  53318. * Called once per frame by the engine.
  53319. */
  53320. update(): void;
  53321. /**
  53322. * Called once for each button that changed state since the last frame
  53323. * @param buttonIdx Which button index changed
  53324. * @param state New state of the button
  53325. * @param changes Which properties on the state changed since last frame
  53326. */
  53327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53328. /**
  53329. * Moves the buttons on the controller mesh based on their current state
  53330. * @param buttonName the name of the button to move
  53331. * @param buttonValue the value of the button which determines the buttons new position
  53332. */
  53333. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53334. /**
  53335. * Moves the axis on the controller mesh based on its current state
  53336. * @param axis the index of the axis
  53337. * @param axisValue the value of the axis which determines the meshes new position
  53338. * @hidden
  53339. */
  53340. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53341. /**
  53342. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53343. * @param scene scene in which to add meshes
  53344. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53345. */
  53346. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53347. /**
  53348. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53349. * can be transformed by button presses and axes values, based on this._mapping.
  53350. *
  53351. * @param scene scene in which the meshes exist
  53352. * @param meshes list of meshes that make up the controller model to process
  53353. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53354. */
  53355. private processModel;
  53356. private createMeshInfo;
  53357. /**
  53358. * Gets the ray of the controller in the direction the controller is pointing
  53359. * @param length the length the resulting ray should be
  53360. * @returns a ray in the direction the controller is pointing
  53361. */
  53362. getForwardRay(length?: number): Ray;
  53363. /**
  53364. * Disposes of the controller
  53365. */
  53366. dispose(): void;
  53367. }
  53368. /**
  53369. * This class represents a new windows motion controller in XR.
  53370. */
  53371. export class XRWindowsMotionController extends WindowsMotionController {
  53372. /**
  53373. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53374. */
  53375. protected readonly _mapping: {
  53376. buttons: string[];
  53377. buttonMeshNames: {
  53378. trigger: string;
  53379. menu: string;
  53380. grip: string;
  53381. thumbstick: string;
  53382. trackpad: string;
  53383. };
  53384. buttonObservableNames: {
  53385. trigger: string;
  53386. menu: string;
  53387. grip: string;
  53388. thumbstick: string;
  53389. trackpad: string;
  53390. };
  53391. axisMeshNames: string[];
  53392. pointingPoseMeshName: string;
  53393. };
  53394. /**
  53395. * Construct a new XR-Based windows motion controller
  53396. *
  53397. * @param gamepadInfo the gamepad object from the browser
  53398. */
  53399. constructor(gamepadInfo: any);
  53400. /**
  53401. * holds the thumbstick values (X,Y)
  53402. */
  53403. thumbstickValues: StickValues;
  53404. /**
  53405. * Fired when the thumbstick on this controller is clicked
  53406. */
  53407. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53408. /**
  53409. * Fired when the thumbstick on this controller is modified
  53410. */
  53411. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53412. /**
  53413. * Fired when the touchpad button on this controller is modified
  53414. */
  53415. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53416. /**
  53417. * Fired when the touchpad values on this controller are modified
  53418. */
  53419. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53420. /**
  53421. * Fired when the thumbstick button on this controller is modified
  53422. * here to prevent breaking changes
  53423. */
  53424. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53425. /**
  53426. * updating the thumbstick(!) and not the trackpad.
  53427. * This is named this way due to the difference between WebVR and XR and to avoid
  53428. * changing the parent class.
  53429. */
  53430. protected _updateTrackpad(): void;
  53431. /**
  53432. * Disposes the class with joy
  53433. */
  53434. dispose(): void;
  53435. }
  53436. }
  53437. declare module BABYLON {
  53438. /**
  53439. * Class containing static functions to help procedurally build meshes
  53440. */
  53441. export class PolyhedronBuilder {
  53442. /**
  53443. * Creates a polyhedron mesh
  53444. * * 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
  53445. * * The parameter `size` (positive float, default 1) sets the polygon size
  53446. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53447. * * 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`
  53448. * * 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
  53449. * * 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)`)
  53450. * * 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
  53451. * * 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
  53452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53453. * * 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
  53454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53455. * @param name defines the name of the mesh
  53456. * @param options defines the options used to create the mesh
  53457. * @param scene defines the hosting scene
  53458. * @returns the polyhedron mesh
  53459. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53460. */
  53461. static CreatePolyhedron(name: string, options: {
  53462. type?: number;
  53463. size?: number;
  53464. sizeX?: number;
  53465. sizeY?: number;
  53466. sizeZ?: number;
  53467. custom?: any;
  53468. faceUV?: Vector4[];
  53469. faceColors?: Color4[];
  53470. flat?: boolean;
  53471. updatable?: boolean;
  53472. sideOrientation?: number;
  53473. frontUVs?: Vector4;
  53474. backUVs?: Vector4;
  53475. }, scene?: Nullable<Scene>): Mesh;
  53476. }
  53477. }
  53478. declare module BABYLON {
  53479. /**
  53480. * Gizmo that enables scaling a mesh along 3 axis
  53481. */
  53482. export class ScaleGizmo extends Gizmo {
  53483. /**
  53484. * Internal gizmo used for interactions on the x axis
  53485. */
  53486. xGizmo: AxisScaleGizmo;
  53487. /**
  53488. * Internal gizmo used for interactions on the y axis
  53489. */
  53490. yGizmo: AxisScaleGizmo;
  53491. /**
  53492. * Internal gizmo used for interactions on the z axis
  53493. */
  53494. zGizmo: AxisScaleGizmo;
  53495. /**
  53496. * Internal gizmo used to scale all axis equally
  53497. */
  53498. uniformScaleGizmo: AxisScaleGizmo;
  53499. private _meshAttached;
  53500. private _nodeAttached;
  53501. private _snapDistance;
  53502. private _uniformScalingMesh;
  53503. private _octahedron;
  53504. private _sensitivity;
  53505. /** Fires an event when any of it's sub gizmos are dragged */
  53506. onDragStartObservable: Observable<unknown>;
  53507. /** Fires an event when any of it's sub gizmos are released from dragging */
  53508. onDragEndObservable: Observable<unknown>;
  53509. get attachedMesh(): Nullable<AbstractMesh>;
  53510. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53511. get attachedNode(): Nullable<Node>;
  53512. set attachedNode(node: Nullable<Node>);
  53513. /**
  53514. * Creates a ScaleGizmo
  53515. * @param gizmoLayer The utility layer the gizmo will be added to
  53516. * @param thickness display gizmo axis thickness
  53517. */
  53518. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53519. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53520. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53521. /**
  53522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53523. */
  53524. set snapDistance(value: number);
  53525. get snapDistance(): number;
  53526. /**
  53527. * Ratio for the scale of the gizmo (Default: 1)
  53528. */
  53529. set scaleRatio(value: number);
  53530. get scaleRatio(): number;
  53531. /**
  53532. * Sensitivity factor for dragging (Default: 1)
  53533. */
  53534. set sensitivity(value: number);
  53535. get sensitivity(): number;
  53536. /**
  53537. * Disposes of the gizmo
  53538. */
  53539. dispose(): void;
  53540. }
  53541. }
  53542. declare module BABYLON {
  53543. /**
  53544. * Single axis scale gizmo
  53545. */
  53546. export class AxisScaleGizmo extends Gizmo {
  53547. /**
  53548. * Drag behavior responsible for the gizmos dragging interactions
  53549. */
  53550. dragBehavior: PointerDragBehavior;
  53551. private _pointerObserver;
  53552. /**
  53553. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53554. */
  53555. snapDistance: number;
  53556. /**
  53557. * Event that fires each time the gizmo snaps to a new location.
  53558. * * snapDistance is the the change in distance
  53559. */
  53560. onSnapObservable: Observable<{
  53561. snapDistance: number;
  53562. }>;
  53563. /**
  53564. * If the scaling operation should be done on all axis (default: false)
  53565. */
  53566. uniformScaling: boolean;
  53567. /**
  53568. * Custom sensitivity value for the drag strength
  53569. */
  53570. sensitivity: number;
  53571. private _isEnabled;
  53572. private _parent;
  53573. private _arrow;
  53574. private _coloredMaterial;
  53575. private _hoverMaterial;
  53576. /**
  53577. * Creates an AxisScaleGizmo
  53578. * @param gizmoLayer The utility layer the gizmo will be added to
  53579. * @param dragAxis The axis which the gizmo will be able to scale on
  53580. * @param color The color of the gizmo
  53581. * @param thickness display gizmo axis thickness
  53582. */
  53583. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53584. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53585. /**
  53586. * If the gizmo is enabled
  53587. */
  53588. set isEnabled(value: boolean);
  53589. get isEnabled(): boolean;
  53590. /**
  53591. * Disposes of the gizmo
  53592. */
  53593. dispose(): void;
  53594. /**
  53595. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53596. * @param mesh The mesh to replace the default mesh of the gizmo
  53597. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53598. */
  53599. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53600. }
  53601. }
  53602. declare module BABYLON {
  53603. /**
  53604. * Bounding box gizmo
  53605. */
  53606. export class BoundingBoxGizmo extends Gizmo {
  53607. private _lineBoundingBox;
  53608. private _rotateSpheresParent;
  53609. private _scaleBoxesParent;
  53610. private _boundingDimensions;
  53611. private _renderObserver;
  53612. private _pointerObserver;
  53613. private _scaleDragSpeed;
  53614. private _tmpQuaternion;
  53615. private _tmpVector;
  53616. private _tmpRotationMatrix;
  53617. /**
  53618. * 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)
  53619. */
  53620. ignoreChildren: boolean;
  53621. /**
  53622. * 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)
  53623. */
  53624. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53625. /**
  53626. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53627. */
  53628. rotationSphereSize: number;
  53629. /**
  53630. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53631. */
  53632. scaleBoxSize: number;
  53633. /**
  53634. * 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)
  53635. */
  53636. fixedDragMeshScreenSize: boolean;
  53637. /**
  53638. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53639. */
  53640. fixedDragMeshScreenSizeDistanceFactor: number;
  53641. /**
  53642. * Fired when a rotation sphere or scale box is dragged
  53643. */
  53644. onDragStartObservable: Observable<{}>;
  53645. /**
  53646. * Fired when a scale box is dragged
  53647. */
  53648. onScaleBoxDragObservable: Observable<{}>;
  53649. /**
  53650. * Fired when a scale box drag is ended
  53651. */
  53652. onScaleBoxDragEndObservable: Observable<{}>;
  53653. /**
  53654. * Fired when a rotation sphere is dragged
  53655. */
  53656. onRotationSphereDragObservable: Observable<{}>;
  53657. /**
  53658. * Fired when a rotation sphere drag is ended
  53659. */
  53660. onRotationSphereDragEndObservable: Observable<{}>;
  53661. /**
  53662. * 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)
  53663. */
  53664. scalePivot: Nullable<Vector3>;
  53665. /**
  53666. * Mesh used as a pivot to rotate the attached node
  53667. */
  53668. private _anchorMesh;
  53669. private _existingMeshScale;
  53670. private _dragMesh;
  53671. private pointerDragBehavior;
  53672. private coloredMaterial;
  53673. private hoverColoredMaterial;
  53674. /**
  53675. * Sets the color of the bounding box gizmo
  53676. * @param color the color to set
  53677. */
  53678. setColor(color: Color3): void;
  53679. /**
  53680. * Creates an BoundingBoxGizmo
  53681. * @param gizmoLayer The utility layer the gizmo will be added to
  53682. * @param color The color of the gizmo
  53683. */
  53684. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53685. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53686. private _selectNode;
  53687. /**
  53688. * Updates the bounding box information for the Gizmo
  53689. */
  53690. updateBoundingBox(): void;
  53691. private _updateRotationSpheres;
  53692. private _updateScaleBoxes;
  53693. /**
  53694. * Enables rotation on the specified axis and disables rotation on the others
  53695. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53696. */
  53697. setEnabledRotationAxis(axis: string): void;
  53698. /**
  53699. * Enables/disables scaling
  53700. * @param enable if scaling should be enabled
  53701. * @param homogeneousScaling defines if scaling should only be homogeneous
  53702. */
  53703. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53704. private _updateDummy;
  53705. /**
  53706. * Enables a pointer drag behavior on the bounding box of the gizmo
  53707. */
  53708. enableDragBehavior(): void;
  53709. /**
  53710. * Disposes of the gizmo
  53711. */
  53712. dispose(): void;
  53713. /**
  53714. * 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)
  53715. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53716. * @returns the bounding box mesh with the passed in mesh as a child
  53717. */
  53718. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53719. /**
  53720. * CustomMeshes are not supported by this gizmo
  53721. * @param mesh The mesh to replace the default mesh of the gizmo
  53722. */
  53723. setCustomMesh(mesh: Mesh): void;
  53724. }
  53725. }
  53726. declare module BABYLON {
  53727. /**
  53728. * Single plane rotation gizmo
  53729. */
  53730. export class PlaneRotationGizmo extends Gizmo {
  53731. /**
  53732. * Drag behavior responsible for the gizmos dragging interactions
  53733. */
  53734. dragBehavior: PointerDragBehavior;
  53735. private _pointerObserver;
  53736. /**
  53737. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53738. */
  53739. snapDistance: number;
  53740. /**
  53741. * Event that fires each time the gizmo snaps to a new location.
  53742. * * snapDistance is the the change in distance
  53743. */
  53744. onSnapObservable: Observable<{
  53745. snapDistance: number;
  53746. }>;
  53747. private _isEnabled;
  53748. private _parent;
  53749. /**
  53750. * Creates a PlaneRotationGizmo
  53751. * @param gizmoLayer The utility layer the gizmo will be added to
  53752. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53753. * @param color The color of the gizmo
  53754. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53755. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53756. * @param thickness display gizmo axis thickness
  53757. */
  53758. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53759. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53760. /**
  53761. * If the gizmo is enabled
  53762. */
  53763. set isEnabled(value: boolean);
  53764. get isEnabled(): boolean;
  53765. /**
  53766. * Disposes of the gizmo
  53767. */
  53768. dispose(): void;
  53769. }
  53770. }
  53771. declare module BABYLON {
  53772. /**
  53773. * Gizmo that enables rotating a mesh along 3 axis
  53774. */
  53775. export class RotationGizmo extends Gizmo {
  53776. /**
  53777. * Internal gizmo used for interactions on the x axis
  53778. */
  53779. xGizmo: PlaneRotationGizmo;
  53780. /**
  53781. * Internal gizmo used for interactions on the y axis
  53782. */
  53783. yGizmo: PlaneRotationGizmo;
  53784. /**
  53785. * Internal gizmo used for interactions on the z axis
  53786. */
  53787. zGizmo: PlaneRotationGizmo;
  53788. /** Fires an event when any of it's sub gizmos are dragged */
  53789. onDragStartObservable: Observable<unknown>;
  53790. /** Fires an event when any of it's sub gizmos are released from dragging */
  53791. onDragEndObservable: Observable<unknown>;
  53792. private _meshAttached;
  53793. private _nodeAttached;
  53794. get attachedMesh(): Nullable<AbstractMesh>;
  53795. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53796. get attachedNode(): Nullable<Node>;
  53797. set attachedNode(node: Nullable<Node>);
  53798. /**
  53799. * Creates a RotationGizmo
  53800. * @param gizmoLayer The utility layer the gizmo will be added to
  53801. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53802. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53803. * @param thickness display gizmo axis thickness
  53804. */
  53805. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53806. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53807. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53808. /**
  53809. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53810. */
  53811. set snapDistance(value: number);
  53812. get snapDistance(): number;
  53813. /**
  53814. * Ratio for the scale of the gizmo (Default: 1)
  53815. */
  53816. set scaleRatio(value: number);
  53817. get scaleRatio(): number;
  53818. /**
  53819. * Disposes of the gizmo
  53820. */
  53821. dispose(): void;
  53822. /**
  53823. * CustomMeshes are not supported by this gizmo
  53824. * @param mesh The mesh to replace the default mesh of the gizmo
  53825. */
  53826. setCustomMesh(mesh: Mesh): void;
  53827. }
  53828. }
  53829. declare module BABYLON {
  53830. /**
  53831. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53832. */
  53833. export class GizmoManager implements IDisposable {
  53834. private scene;
  53835. /**
  53836. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53837. */
  53838. gizmos: {
  53839. positionGizmo: Nullable<PositionGizmo>;
  53840. rotationGizmo: Nullable<RotationGizmo>;
  53841. scaleGizmo: Nullable<ScaleGizmo>;
  53842. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53843. };
  53844. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53845. clearGizmoOnEmptyPointerEvent: boolean;
  53846. /** Fires an event when the manager is attached to a mesh */
  53847. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53848. /** Fires an event when the manager is attached to a node */
  53849. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53850. private _gizmosEnabled;
  53851. private _pointerObserver;
  53852. private _attachedMesh;
  53853. private _attachedNode;
  53854. private _boundingBoxColor;
  53855. private _defaultUtilityLayer;
  53856. private _defaultKeepDepthUtilityLayer;
  53857. private _thickness;
  53858. /**
  53859. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53860. */
  53861. boundingBoxDragBehavior: SixDofDragBehavior;
  53862. /**
  53863. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53864. */
  53865. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53866. /**
  53867. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53868. */
  53869. attachableNodes: Nullable<Array<Node>>;
  53870. /**
  53871. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53872. */
  53873. usePointerToAttachGizmos: boolean;
  53874. /**
  53875. * Utility layer that the bounding box gizmo belongs to
  53876. */
  53877. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53878. /**
  53879. * Utility layer that all gizmos besides bounding box belong to
  53880. */
  53881. get utilityLayer(): UtilityLayerRenderer;
  53882. /**
  53883. * Instatiates a gizmo manager
  53884. * @param scene the scene to overlay the gizmos on top of
  53885. * @param thickness display gizmo axis thickness
  53886. */
  53887. constructor(scene: Scene, thickness?: number);
  53888. /**
  53889. * Attaches a set of gizmos to the specified mesh
  53890. * @param mesh The mesh the gizmo's should be attached to
  53891. */
  53892. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53893. /**
  53894. * Attaches a set of gizmos to the specified node
  53895. * @param node The node the gizmo's should be attached to
  53896. */
  53897. attachToNode(node: Nullable<Node>): void;
  53898. /**
  53899. * If the position gizmo is enabled
  53900. */
  53901. set positionGizmoEnabled(value: boolean);
  53902. get positionGizmoEnabled(): boolean;
  53903. /**
  53904. * If the rotation gizmo is enabled
  53905. */
  53906. set rotationGizmoEnabled(value: boolean);
  53907. get rotationGizmoEnabled(): boolean;
  53908. /**
  53909. * If the scale gizmo is enabled
  53910. */
  53911. set scaleGizmoEnabled(value: boolean);
  53912. get scaleGizmoEnabled(): boolean;
  53913. /**
  53914. * If the boundingBox gizmo is enabled
  53915. */
  53916. set boundingBoxGizmoEnabled(value: boolean);
  53917. get boundingBoxGizmoEnabled(): boolean;
  53918. /**
  53919. * Disposes of the gizmo manager
  53920. */
  53921. dispose(): void;
  53922. }
  53923. }
  53924. declare module BABYLON {
  53925. /**
  53926. * A directional light is defined by a direction (what a surprise!).
  53927. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53928. * 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.
  53929. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53930. */
  53931. export class DirectionalLight extends ShadowLight {
  53932. private _shadowFrustumSize;
  53933. /**
  53934. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53935. */
  53936. get shadowFrustumSize(): number;
  53937. /**
  53938. * Specifies a fix frustum size for the shadow generation.
  53939. */
  53940. set shadowFrustumSize(value: number);
  53941. private _shadowOrthoScale;
  53942. /**
  53943. * Gets the shadow projection scale against the optimal computed one.
  53944. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53945. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53946. */
  53947. get shadowOrthoScale(): number;
  53948. /**
  53949. * Sets the shadow projection scale against the optimal computed one.
  53950. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53951. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53952. */
  53953. set shadowOrthoScale(value: number);
  53954. /**
  53955. * Automatically compute the projection matrix to best fit (including all the casters)
  53956. * on each frame.
  53957. */
  53958. autoUpdateExtends: boolean;
  53959. /**
  53960. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53961. * on each frame. autoUpdateExtends must be set to true for this to work
  53962. */
  53963. autoCalcShadowZBounds: boolean;
  53964. private _orthoLeft;
  53965. private _orthoRight;
  53966. private _orthoTop;
  53967. private _orthoBottom;
  53968. /**
  53969. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53970. * The directional light is emitted from everywhere in the given direction.
  53971. * It can cast shadows.
  53972. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53973. * @param name The friendly name of the light
  53974. * @param direction The direction of the light
  53975. * @param scene The scene the light belongs to
  53976. */
  53977. constructor(name: string, direction: Vector3, scene: Scene);
  53978. /**
  53979. * Returns the string "DirectionalLight".
  53980. * @return The class name
  53981. */
  53982. getClassName(): string;
  53983. /**
  53984. * Returns the integer 1.
  53985. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53986. */
  53987. getTypeID(): number;
  53988. /**
  53989. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53990. * Returns the DirectionalLight Shadow projection matrix.
  53991. */
  53992. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53993. /**
  53994. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53995. * Returns the DirectionalLight Shadow projection matrix.
  53996. */
  53997. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53998. /**
  53999. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54000. * Returns the DirectionalLight Shadow projection matrix.
  54001. */
  54002. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54003. protected _buildUniformLayout(): void;
  54004. /**
  54005. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54006. * @param effect The effect to update
  54007. * @param lightIndex The index of the light in the effect to update
  54008. * @returns The directional light
  54009. */
  54010. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54011. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54012. /**
  54013. * Gets the minZ used for shadow according to both the scene and the light.
  54014. *
  54015. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54016. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54017. * @param activeCamera The camera we are returning the min for
  54018. * @returns the depth min z
  54019. */
  54020. getDepthMinZ(activeCamera: Camera): number;
  54021. /**
  54022. * Gets the maxZ used for shadow according to both the scene and the light.
  54023. *
  54024. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54025. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54026. * @param activeCamera The camera we are returning the max for
  54027. * @returns the depth max z
  54028. */
  54029. getDepthMaxZ(activeCamera: Camera): number;
  54030. /**
  54031. * Prepares the list of defines specific to the light type.
  54032. * @param defines the list of defines
  54033. * @param lightIndex defines the index of the light for the effect
  54034. */
  54035. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54036. }
  54037. }
  54038. declare module BABYLON {
  54039. /**
  54040. * Class containing static functions to help procedurally build meshes
  54041. */
  54042. export class HemisphereBuilder {
  54043. /**
  54044. * Creates a hemisphere mesh
  54045. * @param name defines the name of the mesh
  54046. * @param options defines the options used to create the mesh
  54047. * @param scene defines the hosting scene
  54048. * @returns the hemisphere mesh
  54049. */
  54050. static CreateHemisphere(name: string, options: {
  54051. segments?: number;
  54052. diameter?: number;
  54053. sideOrientation?: number;
  54054. }, scene: any): Mesh;
  54055. }
  54056. }
  54057. declare module BABYLON {
  54058. /**
  54059. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54060. * These values define a cone of light starting from the position, emitting toward the direction.
  54061. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54062. * and the exponent defines the speed of the decay of the light with distance (reach).
  54063. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54064. */
  54065. export class SpotLight extends ShadowLight {
  54066. private _angle;
  54067. private _innerAngle;
  54068. private _cosHalfAngle;
  54069. private _lightAngleScale;
  54070. private _lightAngleOffset;
  54071. /**
  54072. * Gets the cone angle of the spot light in Radians.
  54073. */
  54074. get angle(): number;
  54075. /**
  54076. * Sets the cone angle of the spot light in Radians.
  54077. */
  54078. set angle(value: number);
  54079. /**
  54080. * Only used in gltf falloff mode, this defines the angle where
  54081. * the directional falloff will start before cutting at angle which could be seen
  54082. * as outer angle.
  54083. */
  54084. get innerAngle(): number;
  54085. /**
  54086. * Only used in gltf falloff mode, this defines the angle where
  54087. * the directional falloff will start before cutting at angle which could be seen
  54088. * as outer angle.
  54089. */
  54090. set innerAngle(value: number);
  54091. private _shadowAngleScale;
  54092. /**
  54093. * Allows scaling the angle of the light for shadow generation only.
  54094. */
  54095. get shadowAngleScale(): number;
  54096. /**
  54097. * Allows scaling the angle of the light for shadow generation only.
  54098. */
  54099. set shadowAngleScale(value: number);
  54100. /**
  54101. * The light decay speed with the distance from the emission spot.
  54102. */
  54103. exponent: number;
  54104. private _projectionTextureMatrix;
  54105. /**
  54106. * Allows reading the projecton texture
  54107. */
  54108. get projectionTextureMatrix(): Matrix;
  54109. protected _projectionTextureLightNear: number;
  54110. /**
  54111. * Gets the near clip of the Spotlight for texture projection.
  54112. */
  54113. get projectionTextureLightNear(): number;
  54114. /**
  54115. * Sets the near clip of the Spotlight for texture projection.
  54116. */
  54117. set projectionTextureLightNear(value: number);
  54118. protected _projectionTextureLightFar: number;
  54119. /**
  54120. * Gets the far clip of the Spotlight for texture projection.
  54121. */
  54122. get projectionTextureLightFar(): number;
  54123. /**
  54124. * Sets the far clip of the Spotlight for texture projection.
  54125. */
  54126. set projectionTextureLightFar(value: number);
  54127. protected _projectionTextureUpDirection: Vector3;
  54128. /**
  54129. * Gets the Up vector of the Spotlight for texture projection.
  54130. */
  54131. get projectionTextureUpDirection(): Vector3;
  54132. /**
  54133. * Sets the Up vector of the Spotlight for texture projection.
  54134. */
  54135. set projectionTextureUpDirection(value: Vector3);
  54136. private _projectionTexture;
  54137. /**
  54138. * Gets the projection texture of the light.
  54139. */
  54140. get projectionTexture(): Nullable<BaseTexture>;
  54141. /**
  54142. * Sets the projection texture of the light.
  54143. */
  54144. set projectionTexture(value: Nullable<BaseTexture>);
  54145. private _projectionTextureViewLightDirty;
  54146. private _projectionTextureProjectionLightDirty;
  54147. private _projectionTextureDirty;
  54148. private _projectionTextureViewTargetVector;
  54149. private _projectionTextureViewLightMatrix;
  54150. private _projectionTextureProjectionLightMatrix;
  54151. private _projectionTextureScalingMatrix;
  54152. /**
  54153. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54154. * It can cast shadows.
  54155. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54156. * @param name The light friendly name
  54157. * @param position The position of the spot light in the scene
  54158. * @param direction The direction of the light in the scene
  54159. * @param angle The cone angle of the light in Radians
  54160. * @param exponent The light decay speed with the distance from the emission spot
  54161. * @param scene The scene the lights belongs to
  54162. */
  54163. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54164. /**
  54165. * Returns the string "SpotLight".
  54166. * @returns the class name
  54167. */
  54168. getClassName(): string;
  54169. /**
  54170. * Returns the integer 2.
  54171. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54172. */
  54173. getTypeID(): number;
  54174. /**
  54175. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54176. */
  54177. protected _setDirection(value: Vector3): void;
  54178. /**
  54179. * Overrides the position setter to recompute the projection texture view light Matrix.
  54180. */
  54181. protected _setPosition(value: Vector3): void;
  54182. /**
  54183. * 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.
  54184. * Returns the SpotLight.
  54185. */
  54186. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54187. protected _computeProjectionTextureViewLightMatrix(): void;
  54188. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54189. /**
  54190. * Main function for light texture projection matrix computing.
  54191. */
  54192. protected _computeProjectionTextureMatrix(): void;
  54193. protected _buildUniformLayout(): void;
  54194. private _computeAngleValues;
  54195. /**
  54196. * Sets the passed Effect "effect" with the Light textures.
  54197. * @param effect The effect to update
  54198. * @param lightIndex The index of the light in the effect to update
  54199. * @returns The light
  54200. */
  54201. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54202. /**
  54203. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54204. * @param effect The effect to update
  54205. * @param lightIndex The index of the light in the effect to update
  54206. * @returns The spot light
  54207. */
  54208. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54209. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54210. /**
  54211. * Disposes the light and the associated resources.
  54212. */
  54213. dispose(): void;
  54214. /**
  54215. * Prepares the list of defines specific to the light type.
  54216. * @param defines the list of defines
  54217. * @param lightIndex defines the index of the light for the effect
  54218. */
  54219. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54220. }
  54221. }
  54222. declare module BABYLON {
  54223. /**
  54224. * Gizmo that enables viewing a light
  54225. */
  54226. export class LightGizmo extends Gizmo {
  54227. private _lightMesh;
  54228. private _material;
  54229. private _cachedPosition;
  54230. private _cachedForward;
  54231. private _attachedMeshParent;
  54232. private _pointerObserver;
  54233. /**
  54234. * Event that fires each time the gizmo is clicked
  54235. */
  54236. onClickedObservable: Observable<Light>;
  54237. /**
  54238. * Creates a LightGizmo
  54239. * @param gizmoLayer The utility layer the gizmo will be added to
  54240. */
  54241. constructor(gizmoLayer?: UtilityLayerRenderer);
  54242. private _light;
  54243. /**
  54244. * The light that the gizmo is attached to
  54245. */
  54246. set light(light: Nullable<Light>);
  54247. get light(): Nullable<Light>;
  54248. /**
  54249. * Gets the material used to render the light gizmo
  54250. */
  54251. get material(): StandardMaterial;
  54252. /**
  54253. * @hidden
  54254. * Updates the gizmo to match the attached mesh's position/rotation
  54255. */
  54256. protected _update(): void;
  54257. private static _Scale;
  54258. /**
  54259. * Creates the lines for a light mesh
  54260. */
  54261. private static _CreateLightLines;
  54262. /**
  54263. * Disposes of the light gizmo
  54264. */
  54265. dispose(): void;
  54266. private static _CreateHemisphericLightMesh;
  54267. private static _CreatePointLightMesh;
  54268. private static _CreateSpotLightMesh;
  54269. private static _CreateDirectionalLightMesh;
  54270. }
  54271. }
  54272. declare module BABYLON {
  54273. /**
  54274. * Gizmo that enables viewing a camera
  54275. */
  54276. export class CameraGizmo extends Gizmo {
  54277. private _cameraMesh;
  54278. private _cameraLinesMesh;
  54279. private _material;
  54280. private _pointerObserver;
  54281. /**
  54282. * Event that fires each time the gizmo is clicked
  54283. */
  54284. onClickedObservable: Observable<Camera>;
  54285. /**
  54286. * Creates a CameraGizmo
  54287. * @param gizmoLayer The utility layer the gizmo will be added to
  54288. */
  54289. constructor(gizmoLayer?: UtilityLayerRenderer);
  54290. private _camera;
  54291. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54292. get displayFrustum(): boolean;
  54293. set displayFrustum(value: boolean);
  54294. /**
  54295. * The camera that the gizmo is attached to
  54296. */
  54297. set camera(camera: Nullable<Camera>);
  54298. get camera(): Nullable<Camera>;
  54299. /**
  54300. * Gets the material used to render the camera gizmo
  54301. */
  54302. get material(): StandardMaterial;
  54303. /**
  54304. * @hidden
  54305. * Updates the gizmo to match the attached mesh's position/rotation
  54306. */
  54307. protected _update(): void;
  54308. private static _Scale;
  54309. private _invProjection;
  54310. /**
  54311. * Disposes of the camera gizmo
  54312. */
  54313. dispose(): void;
  54314. private static _CreateCameraMesh;
  54315. private static _CreateCameraFrustum;
  54316. }
  54317. }
  54318. declare module BABYLON {
  54319. /** @hidden */
  54320. export var backgroundFragmentDeclaration: {
  54321. name: string;
  54322. shader: string;
  54323. };
  54324. }
  54325. declare module BABYLON {
  54326. /** @hidden */
  54327. export var backgroundUboDeclaration: {
  54328. name: string;
  54329. shader: string;
  54330. };
  54331. }
  54332. declare module BABYLON {
  54333. /** @hidden */
  54334. export var backgroundPixelShader: {
  54335. name: string;
  54336. shader: string;
  54337. };
  54338. }
  54339. declare module BABYLON {
  54340. /** @hidden */
  54341. export var backgroundVertexDeclaration: {
  54342. name: string;
  54343. shader: string;
  54344. };
  54345. }
  54346. declare module BABYLON {
  54347. /** @hidden */
  54348. export var backgroundVertexShader: {
  54349. name: string;
  54350. shader: string;
  54351. };
  54352. }
  54353. declare module BABYLON {
  54354. /**
  54355. * Background material used to create an efficient environement around your scene.
  54356. */
  54357. export class BackgroundMaterial extends PushMaterial {
  54358. /**
  54359. * Standard reflectance value at parallel view angle.
  54360. */
  54361. static StandardReflectance0: number;
  54362. /**
  54363. * Standard reflectance value at grazing angle.
  54364. */
  54365. static StandardReflectance90: number;
  54366. protected _primaryColor: Color3;
  54367. /**
  54368. * Key light Color (multiply against the environement texture)
  54369. */
  54370. primaryColor: Color3;
  54371. protected __perceptualColor: Nullable<Color3>;
  54372. /**
  54373. * Experimental Internal Use Only.
  54374. *
  54375. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54376. * This acts as a helper to set the primary color to a more "human friendly" value.
  54377. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54378. * output color as close as possible from the chosen value.
  54379. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54380. * part of lighting setup.)
  54381. */
  54382. get _perceptualColor(): Nullable<Color3>;
  54383. set _perceptualColor(value: Nullable<Color3>);
  54384. protected _primaryColorShadowLevel: float;
  54385. /**
  54386. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54387. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54388. */
  54389. get primaryColorShadowLevel(): float;
  54390. set primaryColorShadowLevel(value: float);
  54391. protected _primaryColorHighlightLevel: float;
  54392. /**
  54393. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54394. * The primary color is used at the level chosen to define what the white area would look.
  54395. */
  54396. get primaryColorHighlightLevel(): float;
  54397. set primaryColorHighlightLevel(value: float);
  54398. protected _reflectionTexture: Nullable<BaseTexture>;
  54399. /**
  54400. * Reflection Texture used in the material.
  54401. * Should be author in a specific way for the best result (refer to the documentation).
  54402. */
  54403. reflectionTexture: Nullable<BaseTexture>;
  54404. protected _reflectionBlur: float;
  54405. /**
  54406. * Reflection Texture level of blur.
  54407. *
  54408. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54409. * texture twice.
  54410. */
  54411. reflectionBlur: float;
  54412. protected _diffuseTexture: Nullable<BaseTexture>;
  54413. /**
  54414. * Diffuse Texture used in the material.
  54415. * Should be author in a specific way for the best result (refer to the documentation).
  54416. */
  54417. diffuseTexture: Nullable<BaseTexture>;
  54418. protected _shadowLights: Nullable<IShadowLight[]>;
  54419. /**
  54420. * Specify the list of lights casting shadow on the material.
  54421. * All scene shadow lights will be included if null.
  54422. */
  54423. shadowLights: Nullable<IShadowLight[]>;
  54424. protected _shadowLevel: float;
  54425. /**
  54426. * Helps adjusting the shadow to a softer level if required.
  54427. * 0 means black shadows and 1 means no shadows.
  54428. */
  54429. shadowLevel: float;
  54430. protected _sceneCenter: Vector3;
  54431. /**
  54432. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54433. * It is usually zero but might be interesting to modify according to your setup.
  54434. */
  54435. sceneCenter: Vector3;
  54436. protected _opacityFresnel: boolean;
  54437. /**
  54438. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54439. * This helps ensuring a nice transition when the camera goes under the ground.
  54440. */
  54441. opacityFresnel: boolean;
  54442. protected _reflectionFresnel: boolean;
  54443. /**
  54444. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54445. * This helps adding a mirror texture on the ground.
  54446. */
  54447. reflectionFresnel: boolean;
  54448. protected _reflectionFalloffDistance: number;
  54449. /**
  54450. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54451. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54452. */
  54453. reflectionFalloffDistance: number;
  54454. protected _reflectionAmount: number;
  54455. /**
  54456. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54457. */
  54458. reflectionAmount: number;
  54459. protected _reflectionReflectance0: number;
  54460. /**
  54461. * This specifies the weight of the reflection at grazing angle.
  54462. */
  54463. reflectionReflectance0: number;
  54464. protected _reflectionReflectance90: number;
  54465. /**
  54466. * This specifies the weight of the reflection at a perpendicular point of view.
  54467. */
  54468. reflectionReflectance90: number;
  54469. /**
  54470. * Sets the reflection reflectance fresnel values according to the default standard
  54471. * empirically know to work well :-)
  54472. */
  54473. set reflectionStandardFresnelWeight(value: number);
  54474. protected _useRGBColor: boolean;
  54475. /**
  54476. * Helps to directly use the maps channels instead of their level.
  54477. */
  54478. useRGBColor: boolean;
  54479. protected _enableNoise: boolean;
  54480. /**
  54481. * This helps reducing the banding effect that could occur on the background.
  54482. */
  54483. enableNoise: boolean;
  54484. /**
  54485. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54486. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54487. * Recommended to be keep at 1.0 except for special cases.
  54488. */
  54489. get fovMultiplier(): number;
  54490. set fovMultiplier(value: number);
  54491. private _fovMultiplier;
  54492. /**
  54493. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54494. */
  54495. useEquirectangularFOV: boolean;
  54496. private _maxSimultaneousLights;
  54497. /**
  54498. * Number of Simultaneous lights allowed on the material.
  54499. */
  54500. maxSimultaneousLights: int;
  54501. private _shadowOnly;
  54502. /**
  54503. * Make the material only render shadows
  54504. */
  54505. shadowOnly: boolean;
  54506. /**
  54507. * Default configuration related to image processing available in the Background Material.
  54508. */
  54509. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54510. /**
  54511. * Keep track of the image processing observer to allow dispose and replace.
  54512. */
  54513. private _imageProcessingObserver;
  54514. /**
  54515. * Attaches a new image processing configuration to the PBR Material.
  54516. * @param configuration (if null the scene configuration will be use)
  54517. */
  54518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54519. /**
  54520. * Gets the image processing configuration used either in this material.
  54521. */
  54522. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54523. /**
  54524. * Sets the Default image processing configuration used either in the this material.
  54525. *
  54526. * If sets to null, the scene one is in use.
  54527. */
  54528. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54529. /**
  54530. * Gets wether the color curves effect is enabled.
  54531. */
  54532. get cameraColorCurvesEnabled(): boolean;
  54533. /**
  54534. * Sets wether the color curves effect is enabled.
  54535. */
  54536. set cameraColorCurvesEnabled(value: boolean);
  54537. /**
  54538. * Gets wether the color grading effect is enabled.
  54539. */
  54540. get cameraColorGradingEnabled(): boolean;
  54541. /**
  54542. * Gets wether the color grading effect is enabled.
  54543. */
  54544. set cameraColorGradingEnabled(value: boolean);
  54545. /**
  54546. * Gets wether tonemapping is enabled or not.
  54547. */
  54548. get cameraToneMappingEnabled(): boolean;
  54549. /**
  54550. * Sets wether tonemapping is enabled or not
  54551. */
  54552. set cameraToneMappingEnabled(value: boolean);
  54553. /**
  54554. * The camera exposure used on this material.
  54555. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54556. * This corresponds to a photographic exposure.
  54557. */
  54558. get cameraExposure(): float;
  54559. /**
  54560. * The camera exposure used on this material.
  54561. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54562. * This corresponds to a photographic exposure.
  54563. */
  54564. set cameraExposure(value: float);
  54565. /**
  54566. * Gets The camera contrast used on this material.
  54567. */
  54568. get cameraContrast(): float;
  54569. /**
  54570. * Sets The camera contrast used on this material.
  54571. */
  54572. set cameraContrast(value: float);
  54573. /**
  54574. * Gets the Color Grading 2D Lookup Texture.
  54575. */
  54576. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54577. /**
  54578. * Sets the Color Grading 2D Lookup Texture.
  54579. */
  54580. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54581. /**
  54582. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54583. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54584. * 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;
  54585. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54586. */
  54587. get cameraColorCurves(): Nullable<ColorCurves>;
  54588. /**
  54589. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54590. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54591. * 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;
  54592. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54593. */
  54594. set cameraColorCurves(value: Nullable<ColorCurves>);
  54595. /**
  54596. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54597. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54598. */
  54599. switchToBGR: boolean;
  54600. private _renderTargets;
  54601. private _reflectionControls;
  54602. private _white;
  54603. private _primaryShadowColor;
  54604. private _primaryHighlightColor;
  54605. /**
  54606. * Instantiates a Background Material in the given scene
  54607. * @param name The friendly name of the material
  54608. * @param scene The scene to add the material to
  54609. */
  54610. constructor(name: string, scene: Scene);
  54611. /**
  54612. * Gets a boolean indicating that current material needs to register RTT
  54613. */
  54614. get hasRenderTargetTextures(): boolean;
  54615. /**
  54616. * The entire material has been created in order to prevent overdraw.
  54617. * @returns false
  54618. */
  54619. needAlphaTesting(): boolean;
  54620. /**
  54621. * The entire material has been created in order to prevent overdraw.
  54622. * @returns true if blending is enable
  54623. */
  54624. needAlphaBlending(): boolean;
  54625. /**
  54626. * Checks wether the material is ready to be rendered for a given mesh.
  54627. * @param mesh The mesh to render
  54628. * @param subMesh The submesh to check against
  54629. * @param useInstances Specify wether or not the material is used with instances
  54630. * @returns true if all the dependencies are ready (Textures, Effects...)
  54631. */
  54632. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54633. /**
  54634. * Compute the primary color according to the chosen perceptual color.
  54635. */
  54636. private _computePrimaryColorFromPerceptualColor;
  54637. /**
  54638. * Compute the highlights and shadow colors according to their chosen levels.
  54639. */
  54640. private _computePrimaryColors;
  54641. /**
  54642. * Build the uniform buffer used in the material.
  54643. */
  54644. buildUniformLayout(): void;
  54645. /**
  54646. * Unbind the material.
  54647. */
  54648. unbind(): void;
  54649. /**
  54650. * Bind only the world matrix to the material.
  54651. * @param world The world matrix to bind.
  54652. */
  54653. bindOnlyWorldMatrix(world: Matrix): void;
  54654. /**
  54655. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54656. * @param world The world matrix to bind.
  54657. * @param subMesh The submesh to bind for.
  54658. */
  54659. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54660. /**
  54661. * Checks to see if a texture is used in the material.
  54662. * @param texture - Base texture to use.
  54663. * @returns - Boolean specifying if a texture is used in the material.
  54664. */
  54665. hasTexture(texture: BaseTexture): boolean;
  54666. /**
  54667. * Dispose the material.
  54668. * @param forceDisposeEffect Force disposal of the associated effect.
  54669. * @param forceDisposeTextures Force disposal of the associated textures.
  54670. */
  54671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54672. /**
  54673. * Clones the material.
  54674. * @param name The cloned name.
  54675. * @returns The cloned material.
  54676. */
  54677. clone(name: string): BackgroundMaterial;
  54678. /**
  54679. * Serializes the current material to its JSON representation.
  54680. * @returns The JSON representation.
  54681. */
  54682. serialize(): any;
  54683. /**
  54684. * Gets the class name of the material
  54685. * @returns "BackgroundMaterial"
  54686. */
  54687. getClassName(): string;
  54688. /**
  54689. * Parse a JSON input to create back a background material.
  54690. * @param source The JSON data to parse
  54691. * @param scene The scene to create the parsed material in
  54692. * @param rootUrl The root url of the assets the material depends upon
  54693. * @returns the instantiated BackgroundMaterial.
  54694. */
  54695. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54696. }
  54697. }
  54698. declare module BABYLON {
  54699. /**
  54700. * Represents the different options available during the creation of
  54701. * a Environment helper.
  54702. *
  54703. * This can control the default ground, skybox and image processing setup of your scene.
  54704. */
  54705. export interface IEnvironmentHelperOptions {
  54706. /**
  54707. * Specifies whether or not to create a ground.
  54708. * True by default.
  54709. */
  54710. createGround: boolean;
  54711. /**
  54712. * Specifies the ground size.
  54713. * 15 by default.
  54714. */
  54715. groundSize: number;
  54716. /**
  54717. * The texture used on the ground for the main color.
  54718. * Comes from the BabylonJS CDN by default.
  54719. *
  54720. * Remarks: Can be either a texture or a url.
  54721. */
  54722. groundTexture: string | BaseTexture;
  54723. /**
  54724. * The color mixed in the ground texture by default.
  54725. * BabylonJS clearColor by default.
  54726. */
  54727. groundColor: Color3;
  54728. /**
  54729. * Specifies the ground opacity.
  54730. * 1 by default.
  54731. */
  54732. groundOpacity: number;
  54733. /**
  54734. * Enables the ground to receive shadows.
  54735. * True by default.
  54736. */
  54737. enableGroundShadow: boolean;
  54738. /**
  54739. * Helps preventing the shadow to be fully black on the ground.
  54740. * 0.5 by default.
  54741. */
  54742. groundShadowLevel: number;
  54743. /**
  54744. * Creates a mirror texture attach to the ground.
  54745. * false by default.
  54746. */
  54747. enableGroundMirror: boolean;
  54748. /**
  54749. * Specifies the ground mirror size ratio.
  54750. * 0.3 by default as the default kernel is 64.
  54751. */
  54752. groundMirrorSizeRatio: number;
  54753. /**
  54754. * Specifies the ground mirror blur kernel size.
  54755. * 64 by default.
  54756. */
  54757. groundMirrorBlurKernel: number;
  54758. /**
  54759. * Specifies the ground mirror visibility amount.
  54760. * 1 by default
  54761. */
  54762. groundMirrorAmount: number;
  54763. /**
  54764. * Specifies the ground mirror reflectance weight.
  54765. * This uses the standard weight of the background material to setup the fresnel effect
  54766. * of the mirror.
  54767. * 1 by default.
  54768. */
  54769. groundMirrorFresnelWeight: number;
  54770. /**
  54771. * Specifies the ground mirror Falloff distance.
  54772. * This can helps reducing the size of the reflection.
  54773. * 0 by Default.
  54774. */
  54775. groundMirrorFallOffDistance: number;
  54776. /**
  54777. * Specifies the ground mirror texture type.
  54778. * Unsigned Int by Default.
  54779. */
  54780. groundMirrorTextureType: number;
  54781. /**
  54782. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54783. * the shown objects.
  54784. */
  54785. groundYBias: number;
  54786. /**
  54787. * Specifies whether or not to create a skybox.
  54788. * True by default.
  54789. */
  54790. createSkybox: boolean;
  54791. /**
  54792. * Specifies the skybox size.
  54793. * 20 by default.
  54794. */
  54795. skyboxSize: number;
  54796. /**
  54797. * The texture used on the skybox for the main color.
  54798. * Comes from the BabylonJS CDN by default.
  54799. *
  54800. * Remarks: Can be either a texture or a url.
  54801. */
  54802. skyboxTexture: string | BaseTexture;
  54803. /**
  54804. * The color mixed in the skybox texture by default.
  54805. * BabylonJS clearColor by default.
  54806. */
  54807. skyboxColor: Color3;
  54808. /**
  54809. * The background rotation around the Y axis of the scene.
  54810. * This helps aligning the key lights of your scene with the background.
  54811. * 0 by default.
  54812. */
  54813. backgroundYRotation: number;
  54814. /**
  54815. * Compute automatically the size of the elements to best fit with the scene.
  54816. */
  54817. sizeAuto: boolean;
  54818. /**
  54819. * Default position of the rootMesh if autoSize is not true.
  54820. */
  54821. rootPosition: Vector3;
  54822. /**
  54823. * Sets up the image processing in the scene.
  54824. * true by default.
  54825. */
  54826. setupImageProcessing: boolean;
  54827. /**
  54828. * The texture used as your environment texture in the scene.
  54829. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54830. *
  54831. * Remarks: Can be either a texture or a url.
  54832. */
  54833. environmentTexture: string | BaseTexture;
  54834. /**
  54835. * The value of the exposure to apply to the scene.
  54836. * 0.6 by default if setupImageProcessing is true.
  54837. */
  54838. cameraExposure: number;
  54839. /**
  54840. * The value of the contrast to apply to the scene.
  54841. * 1.6 by default if setupImageProcessing is true.
  54842. */
  54843. cameraContrast: number;
  54844. /**
  54845. * Specifies whether or not tonemapping should be enabled in the scene.
  54846. * true by default if setupImageProcessing is true.
  54847. */
  54848. toneMappingEnabled: boolean;
  54849. }
  54850. /**
  54851. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54852. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54853. * It also helps with the default setup of your imageProcessing configuration.
  54854. */
  54855. export class EnvironmentHelper {
  54856. /**
  54857. * Default ground texture URL.
  54858. */
  54859. private static _groundTextureCDNUrl;
  54860. /**
  54861. * Default skybox texture URL.
  54862. */
  54863. private static _skyboxTextureCDNUrl;
  54864. /**
  54865. * Default environment texture URL.
  54866. */
  54867. private static _environmentTextureCDNUrl;
  54868. /**
  54869. * Creates the default options for the helper.
  54870. */
  54871. private static _getDefaultOptions;
  54872. private _rootMesh;
  54873. /**
  54874. * Gets the root mesh created by the helper.
  54875. */
  54876. get rootMesh(): Mesh;
  54877. private _skybox;
  54878. /**
  54879. * Gets the skybox created by the helper.
  54880. */
  54881. get skybox(): Nullable<Mesh>;
  54882. private _skyboxTexture;
  54883. /**
  54884. * Gets the skybox texture created by the helper.
  54885. */
  54886. get skyboxTexture(): Nullable<BaseTexture>;
  54887. private _skyboxMaterial;
  54888. /**
  54889. * Gets the skybox material created by the helper.
  54890. */
  54891. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54892. private _ground;
  54893. /**
  54894. * Gets the ground mesh created by the helper.
  54895. */
  54896. get ground(): Nullable<Mesh>;
  54897. private _groundTexture;
  54898. /**
  54899. * Gets the ground texture created by the helper.
  54900. */
  54901. get groundTexture(): Nullable<BaseTexture>;
  54902. private _groundMirror;
  54903. /**
  54904. * Gets the ground mirror created by the helper.
  54905. */
  54906. get groundMirror(): Nullable<MirrorTexture>;
  54907. /**
  54908. * Gets the ground mirror render list to helps pushing the meshes
  54909. * you wish in the ground reflection.
  54910. */
  54911. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54912. private _groundMaterial;
  54913. /**
  54914. * Gets the ground material created by the helper.
  54915. */
  54916. get groundMaterial(): Nullable<BackgroundMaterial>;
  54917. /**
  54918. * Stores the creation options.
  54919. */
  54920. private readonly _scene;
  54921. private _options;
  54922. /**
  54923. * This observable will be notified with any error during the creation of the environment,
  54924. * mainly texture creation errors.
  54925. */
  54926. onErrorObservable: Observable<{
  54927. message?: string;
  54928. exception?: any;
  54929. }>;
  54930. /**
  54931. * constructor
  54932. * @param options Defines the options we want to customize the helper
  54933. * @param scene The scene to add the material to
  54934. */
  54935. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54936. /**
  54937. * Updates the background according to the new options
  54938. * @param options
  54939. */
  54940. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54941. /**
  54942. * Sets the primary color of all the available elements.
  54943. * @param color the main color to affect to the ground and the background
  54944. */
  54945. setMainColor(color: Color3): void;
  54946. /**
  54947. * Setup the image processing according to the specified options.
  54948. */
  54949. private _setupImageProcessing;
  54950. /**
  54951. * Setup the environment texture according to the specified options.
  54952. */
  54953. private _setupEnvironmentTexture;
  54954. /**
  54955. * Setup the background according to the specified options.
  54956. */
  54957. private _setupBackground;
  54958. /**
  54959. * Get the scene sizes according to the setup.
  54960. */
  54961. private _getSceneSize;
  54962. /**
  54963. * Setup the ground according to the specified options.
  54964. */
  54965. private _setupGround;
  54966. /**
  54967. * Setup the ground material according to the specified options.
  54968. */
  54969. private _setupGroundMaterial;
  54970. /**
  54971. * Setup the ground diffuse texture according to the specified options.
  54972. */
  54973. private _setupGroundDiffuseTexture;
  54974. /**
  54975. * Setup the ground mirror texture according to the specified options.
  54976. */
  54977. private _setupGroundMirrorTexture;
  54978. /**
  54979. * Setup the ground to receive the mirror texture.
  54980. */
  54981. private _setupMirrorInGroundMaterial;
  54982. /**
  54983. * Setup the skybox according to the specified options.
  54984. */
  54985. private _setupSkybox;
  54986. /**
  54987. * Setup the skybox material according to the specified options.
  54988. */
  54989. private _setupSkyboxMaterial;
  54990. /**
  54991. * Setup the skybox reflection texture according to the specified options.
  54992. */
  54993. private _setupSkyboxReflectionTexture;
  54994. private _errorHandler;
  54995. /**
  54996. * Dispose all the elements created by the Helper.
  54997. */
  54998. dispose(): void;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55004. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55005. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55006. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55007. */
  55008. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55009. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55010. /**
  55011. * Define the source as a Monoscopic panoramic 360/180.
  55012. */
  55013. static readonly MODE_MONOSCOPIC: number;
  55014. /**
  55015. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55016. */
  55017. static readonly MODE_TOPBOTTOM: number;
  55018. /**
  55019. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55020. */
  55021. static readonly MODE_SIDEBYSIDE: number;
  55022. private _halfDome;
  55023. protected _useDirectMapping: boolean;
  55024. /**
  55025. * The texture being displayed on the sphere
  55026. */
  55027. protected _texture: T;
  55028. /**
  55029. * Gets the texture being displayed on the sphere
  55030. */
  55031. get texture(): T;
  55032. /**
  55033. * Sets the texture being displayed on the sphere
  55034. */
  55035. set texture(newTexture: T);
  55036. /**
  55037. * The skybox material
  55038. */
  55039. protected _material: BackgroundMaterial;
  55040. /**
  55041. * The surface used for the dome
  55042. */
  55043. protected _mesh: Mesh;
  55044. /**
  55045. * Gets the mesh used for the dome.
  55046. */
  55047. get mesh(): Mesh;
  55048. /**
  55049. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55050. */
  55051. private _halfDomeMask;
  55052. /**
  55053. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55054. * Also see the options.resolution property.
  55055. */
  55056. get fovMultiplier(): number;
  55057. set fovMultiplier(value: number);
  55058. protected _textureMode: number;
  55059. /**
  55060. * Gets or set the current texture mode for the texture. It can be:
  55061. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55062. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55063. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55064. */
  55065. get textureMode(): number;
  55066. /**
  55067. * Sets the current texture mode for the texture. It can be:
  55068. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55069. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55070. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55071. */
  55072. set textureMode(value: number);
  55073. /**
  55074. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55075. */
  55076. get halfDome(): boolean;
  55077. /**
  55078. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55079. */
  55080. set halfDome(enabled: boolean);
  55081. /**
  55082. * Oberserver used in Stereoscopic VR Mode.
  55083. */
  55084. private _onBeforeCameraRenderObserver;
  55085. /**
  55086. * Observable raised when an error occured while loading the 360 image
  55087. */
  55088. onLoadErrorObservable: Observable<string>;
  55089. /**
  55090. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55091. * @param name Element's name, child elements will append suffixes for their own names.
  55092. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55093. * @param options An object containing optional or exposed sub element properties
  55094. */
  55095. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55096. resolution?: number;
  55097. clickToPlay?: boolean;
  55098. autoPlay?: boolean;
  55099. loop?: boolean;
  55100. size?: number;
  55101. poster?: string;
  55102. faceForward?: boolean;
  55103. useDirectMapping?: boolean;
  55104. halfDomeMode?: boolean;
  55105. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55106. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55107. protected _changeTextureMode(value: number): void;
  55108. /**
  55109. * Releases resources associated with this node.
  55110. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55111. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55112. */
  55113. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55114. }
  55115. }
  55116. declare module BABYLON {
  55117. /**
  55118. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55119. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55120. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55121. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55122. */
  55123. export class PhotoDome extends TextureDome<Texture> {
  55124. /**
  55125. * Define the image as a Monoscopic panoramic 360 image.
  55126. */
  55127. static readonly MODE_MONOSCOPIC: number;
  55128. /**
  55129. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55130. */
  55131. static readonly MODE_TOPBOTTOM: number;
  55132. /**
  55133. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55134. */
  55135. static readonly MODE_SIDEBYSIDE: number;
  55136. /**
  55137. * Gets or sets the texture being displayed on the sphere
  55138. */
  55139. get photoTexture(): Texture;
  55140. /**
  55141. * sets the texture being displayed on the sphere
  55142. */
  55143. set photoTexture(value: Texture);
  55144. /**
  55145. * Gets the current video mode for the video. It can be:
  55146. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55147. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55148. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55149. */
  55150. get imageMode(): number;
  55151. /**
  55152. * Sets the current video mode for the video. It can be:
  55153. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55154. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55155. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55156. */
  55157. set imageMode(value: number);
  55158. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55159. }
  55160. }
  55161. declare module BABYLON {
  55162. /**
  55163. * Class used to host RGBD texture specific utilities
  55164. */
  55165. export class RGBDTextureTools {
  55166. /**
  55167. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55168. * @param texture the texture to expand.
  55169. */
  55170. static ExpandRGBDTexture(texture: Texture): void;
  55171. }
  55172. }
  55173. declare module BABYLON {
  55174. /**
  55175. * Class used to host texture specific utilities
  55176. */
  55177. export class BRDFTextureTools {
  55178. /**
  55179. * Prevents texture cache collision
  55180. */
  55181. private static _instanceNumber;
  55182. /**
  55183. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55184. * @param scene defines the hosting scene
  55185. * @returns the environment BRDF texture
  55186. */
  55187. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55188. private static _environmentBRDFBase64Texture;
  55189. }
  55190. }
  55191. declare module BABYLON {
  55192. /**
  55193. * @hidden
  55194. */
  55195. export interface IMaterialClearCoatDefines {
  55196. CLEARCOAT: boolean;
  55197. CLEARCOAT_DEFAULTIOR: boolean;
  55198. CLEARCOAT_TEXTURE: boolean;
  55199. CLEARCOAT_TEXTUREDIRECTUV: number;
  55200. CLEARCOAT_BUMP: boolean;
  55201. CLEARCOAT_BUMPDIRECTUV: number;
  55202. CLEARCOAT_TINT: boolean;
  55203. CLEARCOAT_TINT_TEXTURE: boolean;
  55204. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55205. /** @hidden */
  55206. _areTexturesDirty: boolean;
  55207. }
  55208. /**
  55209. * Define the code related to the clear coat parameters of the pbr material.
  55210. */
  55211. export class PBRClearCoatConfiguration {
  55212. /**
  55213. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55214. * The default fits with a polyurethane material.
  55215. */
  55216. private static readonly _DefaultIndexOfRefraction;
  55217. private _isEnabled;
  55218. /**
  55219. * Defines if the clear coat is enabled in the material.
  55220. */
  55221. isEnabled: boolean;
  55222. /**
  55223. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55224. */
  55225. intensity: number;
  55226. /**
  55227. * Defines the clear coat layer roughness.
  55228. */
  55229. roughness: number;
  55230. private _indexOfRefraction;
  55231. /**
  55232. * Defines the index of refraction of the clear coat.
  55233. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55234. * The default fits with a polyurethane material.
  55235. * Changing the default value is more performance intensive.
  55236. */
  55237. indexOfRefraction: number;
  55238. private _texture;
  55239. /**
  55240. * Stores the clear coat values in a texture.
  55241. */
  55242. texture: Nullable<BaseTexture>;
  55243. private _bumpTexture;
  55244. /**
  55245. * Define the clear coat specific bump texture.
  55246. */
  55247. bumpTexture: Nullable<BaseTexture>;
  55248. private _isTintEnabled;
  55249. /**
  55250. * Defines if the clear coat tint is enabled in the material.
  55251. */
  55252. isTintEnabled: boolean;
  55253. /**
  55254. * Defines the clear coat tint of the material.
  55255. * This is only use if tint is enabled
  55256. */
  55257. tintColor: Color3;
  55258. /**
  55259. * Defines the distance at which the tint color should be found in the
  55260. * clear coat media.
  55261. * This is only use if tint is enabled
  55262. */
  55263. tintColorAtDistance: number;
  55264. /**
  55265. * Defines the clear coat layer thickness.
  55266. * This is only use if tint is enabled
  55267. */
  55268. tintThickness: number;
  55269. private _tintTexture;
  55270. /**
  55271. * Stores the clear tint values in a texture.
  55272. * rgb is tint
  55273. * a is a thickness factor
  55274. */
  55275. tintTexture: Nullable<BaseTexture>;
  55276. /** @hidden */
  55277. private _internalMarkAllSubMeshesAsTexturesDirty;
  55278. /** @hidden */
  55279. _markAllSubMeshesAsTexturesDirty(): void;
  55280. /**
  55281. * Instantiate a new istance of clear coat configuration.
  55282. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55283. */
  55284. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55285. /**
  55286. * Gets wehter the submesh is ready to be used or not.
  55287. * @param defines the list of "defines" to update.
  55288. * @param scene defines the scene the material belongs to.
  55289. * @param engine defines the engine the material belongs to.
  55290. * @param disableBumpMap defines wether the material disables bump or not.
  55291. * @returns - boolean indicating that the submesh is ready or not.
  55292. */
  55293. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55294. /**
  55295. * Checks to see if a texture is used in the material.
  55296. * @param defines the list of "defines" to update.
  55297. * @param scene defines the scene to the material belongs to.
  55298. */
  55299. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55300. /**
  55301. * Binds the material data.
  55302. * @param uniformBuffer defines the Uniform buffer to fill in.
  55303. * @param scene defines the scene the material belongs to.
  55304. * @param engine defines the engine the material belongs to.
  55305. * @param disableBumpMap defines wether the material disables bump or not.
  55306. * @param isFrozen defines wether the material is frozen or not.
  55307. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55308. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55309. */
  55310. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55311. /**
  55312. * Checks to see if a texture is used in the material.
  55313. * @param texture - Base texture to use.
  55314. * @returns - Boolean specifying if a texture is used in the material.
  55315. */
  55316. hasTexture(texture: BaseTexture): boolean;
  55317. /**
  55318. * Returns an array of the actively used textures.
  55319. * @param activeTextures Array of BaseTextures
  55320. */
  55321. getActiveTextures(activeTextures: BaseTexture[]): void;
  55322. /**
  55323. * Returns the animatable textures.
  55324. * @param animatables Array of animatable textures.
  55325. */
  55326. getAnimatables(animatables: IAnimatable[]): void;
  55327. /**
  55328. * Disposes the resources of the material.
  55329. * @param forceDisposeTextures - Forces the disposal of all textures.
  55330. */
  55331. dispose(forceDisposeTextures?: boolean): void;
  55332. /**
  55333. * Get the current class name of the texture useful for serialization or dynamic coding.
  55334. * @returns "PBRClearCoatConfiguration"
  55335. */
  55336. getClassName(): string;
  55337. /**
  55338. * Add fallbacks to the effect fallbacks list.
  55339. * @param defines defines the Base texture to use.
  55340. * @param fallbacks defines the current fallback list.
  55341. * @param currentRank defines the current fallback rank.
  55342. * @returns the new fallback rank.
  55343. */
  55344. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55345. /**
  55346. * Add the required uniforms to the current list.
  55347. * @param uniforms defines the current uniform list.
  55348. */
  55349. static AddUniforms(uniforms: string[]): void;
  55350. /**
  55351. * Add the required samplers to the current list.
  55352. * @param samplers defines the current sampler list.
  55353. */
  55354. static AddSamplers(samplers: string[]): void;
  55355. /**
  55356. * Add the required uniforms to the current buffer.
  55357. * @param uniformBuffer defines the current uniform buffer.
  55358. */
  55359. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55360. /**
  55361. * Makes a duplicate of the current configuration into another one.
  55362. * @param clearCoatConfiguration define the config where to copy the info
  55363. */
  55364. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55365. /**
  55366. * Serializes this clear coat configuration.
  55367. * @returns - An object with the serialized config.
  55368. */
  55369. serialize(): any;
  55370. /**
  55371. * Parses a anisotropy Configuration from a serialized object.
  55372. * @param source - Serialized object.
  55373. * @param scene Defines the scene we are parsing for
  55374. * @param rootUrl Defines the rootUrl to load from
  55375. */
  55376. parse(source: any, scene: Scene, rootUrl: string): void;
  55377. }
  55378. }
  55379. declare module BABYLON {
  55380. /**
  55381. * @hidden
  55382. */
  55383. export interface IMaterialAnisotropicDefines {
  55384. ANISOTROPIC: boolean;
  55385. ANISOTROPIC_TEXTURE: boolean;
  55386. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55387. MAINUV1: boolean;
  55388. _areTexturesDirty: boolean;
  55389. _needUVs: boolean;
  55390. }
  55391. /**
  55392. * Define the code related to the anisotropic parameters of the pbr material.
  55393. */
  55394. export class PBRAnisotropicConfiguration {
  55395. private _isEnabled;
  55396. /**
  55397. * Defines if the anisotropy is enabled in the material.
  55398. */
  55399. isEnabled: boolean;
  55400. /**
  55401. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55402. */
  55403. intensity: number;
  55404. /**
  55405. * Defines if the effect is along the tangents, bitangents or in between.
  55406. * By default, the effect is "strectching" the highlights along the tangents.
  55407. */
  55408. direction: Vector2;
  55409. private _texture;
  55410. /**
  55411. * Stores the anisotropy values in a texture.
  55412. * rg is direction (like normal from -1 to 1)
  55413. * b is a intensity
  55414. */
  55415. texture: Nullable<BaseTexture>;
  55416. /** @hidden */
  55417. private _internalMarkAllSubMeshesAsTexturesDirty;
  55418. /** @hidden */
  55419. _markAllSubMeshesAsTexturesDirty(): void;
  55420. /**
  55421. * Instantiate a new istance of anisotropy configuration.
  55422. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55423. */
  55424. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55425. /**
  55426. * Specifies that the submesh is ready to be used.
  55427. * @param defines the list of "defines" to update.
  55428. * @param scene defines the scene the material belongs to.
  55429. * @returns - boolean indicating that the submesh is ready or not.
  55430. */
  55431. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55432. /**
  55433. * Checks to see if a texture is used in the material.
  55434. * @param defines the list of "defines" to update.
  55435. * @param mesh the mesh we are preparing the defines for.
  55436. * @param scene defines the scene the material belongs to.
  55437. */
  55438. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55439. /**
  55440. * Binds the material data.
  55441. * @param uniformBuffer defines the Uniform buffer to fill in.
  55442. * @param scene defines the scene the material belongs to.
  55443. * @param isFrozen defines wether the material is frozen or not.
  55444. */
  55445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55446. /**
  55447. * Checks to see if a texture is used in the material.
  55448. * @param texture - Base texture to use.
  55449. * @returns - Boolean specifying if a texture is used in the material.
  55450. */
  55451. hasTexture(texture: BaseTexture): boolean;
  55452. /**
  55453. * Returns an array of the actively used textures.
  55454. * @param activeTextures Array of BaseTextures
  55455. */
  55456. getActiveTextures(activeTextures: BaseTexture[]): void;
  55457. /**
  55458. * Returns the animatable textures.
  55459. * @param animatables Array of animatable textures.
  55460. */
  55461. getAnimatables(animatables: IAnimatable[]): void;
  55462. /**
  55463. * Disposes the resources of the material.
  55464. * @param forceDisposeTextures - Forces the disposal of all textures.
  55465. */
  55466. dispose(forceDisposeTextures?: boolean): void;
  55467. /**
  55468. * Get the current class name of the texture useful for serialization or dynamic coding.
  55469. * @returns "PBRAnisotropicConfiguration"
  55470. */
  55471. getClassName(): string;
  55472. /**
  55473. * Add fallbacks to the effect fallbacks list.
  55474. * @param defines defines the Base texture to use.
  55475. * @param fallbacks defines the current fallback list.
  55476. * @param currentRank defines the current fallback rank.
  55477. * @returns the new fallback rank.
  55478. */
  55479. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55480. /**
  55481. * Add the required uniforms to the current list.
  55482. * @param uniforms defines the current uniform list.
  55483. */
  55484. static AddUniforms(uniforms: string[]): void;
  55485. /**
  55486. * Add the required uniforms to the current buffer.
  55487. * @param uniformBuffer defines the current uniform buffer.
  55488. */
  55489. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55490. /**
  55491. * Add the required samplers to the current list.
  55492. * @param samplers defines the current sampler list.
  55493. */
  55494. static AddSamplers(samplers: string[]): void;
  55495. /**
  55496. * Makes a duplicate of the current configuration into another one.
  55497. * @param anisotropicConfiguration define the config where to copy the info
  55498. */
  55499. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55500. /**
  55501. * Serializes this anisotropy configuration.
  55502. * @returns - An object with the serialized config.
  55503. */
  55504. serialize(): any;
  55505. /**
  55506. * Parses a anisotropy Configuration from a serialized object.
  55507. * @param source - Serialized object.
  55508. * @param scene Defines the scene we are parsing for
  55509. * @param rootUrl Defines the rootUrl to load from
  55510. */
  55511. parse(source: any, scene: Scene, rootUrl: string): void;
  55512. }
  55513. }
  55514. declare module BABYLON {
  55515. /**
  55516. * @hidden
  55517. */
  55518. export interface IMaterialBRDFDefines {
  55519. BRDF_V_HEIGHT_CORRELATED: boolean;
  55520. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55521. SPHERICAL_HARMONICS: boolean;
  55522. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55523. /** @hidden */
  55524. _areMiscDirty: boolean;
  55525. }
  55526. /**
  55527. * Define the code related to the BRDF parameters of the pbr material.
  55528. */
  55529. export class PBRBRDFConfiguration {
  55530. /**
  55531. * Default value used for the energy conservation.
  55532. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55533. */
  55534. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55535. /**
  55536. * Default value used for the Smith Visibility Height Correlated mode.
  55537. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55538. */
  55539. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55540. /**
  55541. * Default value used for the IBL diffuse part.
  55542. * This can help switching back to the polynomials mode globally which is a tiny bit
  55543. * less GPU intensive at the drawback of a lower quality.
  55544. */
  55545. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55546. /**
  55547. * Default value used for activating energy conservation for the specular workflow.
  55548. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55549. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55550. */
  55551. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55552. private _useEnergyConservation;
  55553. /**
  55554. * Defines if the material uses energy conservation.
  55555. */
  55556. useEnergyConservation: boolean;
  55557. private _useSmithVisibilityHeightCorrelated;
  55558. /**
  55559. * LEGACY Mode set to false
  55560. * Defines if the material uses height smith correlated visibility term.
  55561. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55562. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55563. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55564. * Not relying on height correlated will also disable energy conservation.
  55565. */
  55566. useSmithVisibilityHeightCorrelated: boolean;
  55567. private _useSphericalHarmonics;
  55568. /**
  55569. * LEGACY Mode set to false
  55570. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55571. * diffuse part of the IBL.
  55572. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55573. * to the ground truth.
  55574. */
  55575. useSphericalHarmonics: boolean;
  55576. private _useSpecularGlossinessInputEnergyConservation;
  55577. /**
  55578. * Defines if the material uses energy conservation, when the specular workflow is active.
  55579. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55580. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55581. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55582. */
  55583. useSpecularGlossinessInputEnergyConservation: boolean;
  55584. /** @hidden */
  55585. private _internalMarkAllSubMeshesAsMiscDirty;
  55586. /** @hidden */
  55587. _markAllSubMeshesAsMiscDirty(): void;
  55588. /**
  55589. * Instantiate a new istance of clear coat configuration.
  55590. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55591. */
  55592. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55593. /**
  55594. * Checks to see if a texture is used in the material.
  55595. * @param defines the list of "defines" to update.
  55596. */
  55597. prepareDefines(defines: IMaterialBRDFDefines): void;
  55598. /**
  55599. * Get the current class name of the texture useful for serialization or dynamic coding.
  55600. * @returns "PBRClearCoatConfiguration"
  55601. */
  55602. getClassName(): string;
  55603. /**
  55604. * Makes a duplicate of the current configuration into another one.
  55605. * @param brdfConfiguration define the config where to copy the info
  55606. */
  55607. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55608. /**
  55609. * Serializes this BRDF configuration.
  55610. * @returns - An object with the serialized config.
  55611. */
  55612. serialize(): any;
  55613. /**
  55614. * Parses a anisotropy Configuration from a serialized object.
  55615. * @param source - Serialized object.
  55616. * @param scene Defines the scene we are parsing for
  55617. * @param rootUrl Defines the rootUrl to load from
  55618. */
  55619. parse(source: any, scene: Scene, rootUrl: string): void;
  55620. }
  55621. }
  55622. declare module BABYLON {
  55623. /**
  55624. * @hidden
  55625. */
  55626. export interface IMaterialSheenDefines {
  55627. SHEEN: boolean;
  55628. SHEEN_TEXTURE: boolean;
  55629. SHEEN_TEXTUREDIRECTUV: number;
  55630. SHEEN_LINKWITHALBEDO: boolean;
  55631. SHEEN_ROUGHNESS: boolean;
  55632. SHEEN_ALBEDOSCALING: boolean;
  55633. /** @hidden */
  55634. _areTexturesDirty: boolean;
  55635. }
  55636. /**
  55637. * Define the code related to the Sheen parameters of the pbr material.
  55638. */
  55639. export class PBRSheenConfiguration {
  55640. private _isEnabled;
  55641. /**
  55642. * Defines if the material uses sheen.
  55643. */
  55644. isEnabled: boolean;
  55645. private _linkSheenWithAlbedo;
  55646. /**
  55647. * Defines if the sheen is linked to the sheen color.
  55648. */
  55649. linkSheenWithAlbedo: boolean;
  55650. /**
  55651. * Defines the sheen intensity.
  55652. */
  55653. intensity: number;
  55654. /**
  55655. * Defines the sheen color.
  55656. */
  55657. color: Color3;
  55658. private _texture;
  55659. /**
  55660. * Stores the sheen tint values in a texture.
  55661. * rgb is tint
  55662. * a is a intensity or roughness if roughness has been defined
  55663. */
  55664. texture: Nullable<BaseTexture>;
  55665. private _roughness;
  55666. /**
  55667. * Defines the sheen roughness.
  55668. * It is not taken into account if linkSheenWithAlbedo is true.
  55669. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55670. */
  55671. roughness: Nullable<number>;
  55672. private _albedoScaling;
  55673. /**
  55674. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55675. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55676. * making it easier to setup and tweak the effect
  55677. */
  55678. albedoScaling: boolean;
  55679. /** @hidden */
  55680. private _internalMarkAllSubMeshesAsTexturesDirty;
  55681. /** @hidden */
  55682. _markAllSubMeshesAsTexturesDirty(): void;
  55683. /**
  55684. * Instantiate a new istance of clear coat configuration.
  55685. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55686. */
  55687. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55688. /**
  55689. * Specifies that the submesh is ready to be used.
  55690. * @param defines the list of "defines" to update.
  55691. * @param scene defines the scene the material belongs to.
  55692. * @returns - boolean indicating that the submesh is ready or not.
  55693. */
  55694. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55695. /**
  55696. * Checks to see if a texture is used in the material.
  55697. * @param defines the list of "defines" to update.
  55698. * @param scene defines the scene the material belongs to.
  55699. */
  55700. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55701. /**
  55702. * Binds the material data.
  55703. * @param uniformBuffer defines the Uniform buffer to fill in.
  55704. * @param scene defines the scene the material belongs to.
  55705. * @param isFrozen defines wether the material is frozen or not.
  55706. */
  55707. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55708. /**
  55709. * Checks to see if a texture is used in the material.
  55710. * @param texture - Base texture to use.
  55711. * @returns - Boolean specifying if a texture is used in the material.
  55712. */
  55713. hasTexture(texture: BaseTexture): boolean;
  55714. /**
  55715. * Returns an array of the actively used textures.
  55716. * @param activeTextures Array of BaseTextures
  55717. */
  55718. getActiveTextures(activeTextures: BaseTexture[]): void;
  55719. /**
  55720. * Returns the animatable textures.
  55721. * @param animatables Array of animatable textures.
  55722. */
  55723. getAnimatables(animatables: IAnimatable[]): void;
  55724. /**
  55725. * Disposes the resources of the material.
  55726. * @param forceDisposeTextures - Forces the disposal of all textures.
  55727. */
  55728. dispose(forceDisposeTextures?: boolean): void;
  55729. /**
  55730. * Get the current class name of the texture useful for serialization or dynamic coding.
  55731. * @returns "PBRSheenConfiguration"
  55732. */
  55733. getClassName(): string;
  55734. /**
  55735. * Add fallbacks to the effect fallbacks list.
  55736. * @param defines defines the Base texture to use.
  55737. * @param fallbacks defines the current fallback list.
  55738. * @param currentRank defines the current fallback rank.
  55739. * @returns the new fallback rank.
  55740. */
  55741. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55742. /**
  55743. * Add the required uniforms to the current list.
  55744. * @param uniforms defines the current uniform list.
  55745. */
  55746. static AddUniforms(uniforms: string[]): void;
  55747. /**
  55748. * Add the required uniforms to the current buffer.
  55749. * @param uniformBuffer defines the current uniform buffer.
  55750. */
  55751. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55752. /**
  55753. * Add the required samplers to the current list.
  55754. * @param samplers defines the current sampler list.
  55755. */
  55756. static AddSamplers(samplers: string[]): void;
  55757. /**
  55758. * Makes a duplicate of the current configuration into another one.
  55759. * @param sheenConfiguration define the config where to copy the info
  55760. */
  55761. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55762. /**
  55763. * Serializes this BRDF configuration.
  55764. * @returns - An object with the serialized config.
  55765. */
  55766. serialize(): any;
  55767. /**
  55768. * Parses a anisotropy Configuration from a serialized object.
  55769. * @param source - Serialized object.
  55770. * @param scene Defines the scene we are parsing for
  55771. * @param rootUrl Defines the rootUrl to load from
  55772. */
  55773. parse(source: any, scene: Scene, rootUrl: string): void;
  55774. }
  55775. }
  55776. declare module BABYLON {
  55777. /**
  55778. * @hidden
  55779. */
  55780. export interface IMaterialSubSurfaceDefines {
  55781. SUBSURFACE: boolean;
  55782. SS_REFRACTION: boolean;
  55783. SS_TRANSLUCENCY: boolean;
  55784. SS_SCATTERING: boolean;
  55785. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55786. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55787. SS_REFRACTIONMAP_3D: boolean;
  55788. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55789. SS_LODINREFRACTIONALPHA: boolean;
  55790. SS_GAMMAREFRACTION: boolean;
  55791. SS_RGBDREFRACTION: boolean;
  55792. SS_LINEARSPECULARREFRACTION: boolean;
  55793. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55794. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55795. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55796. /** @hidden */
  55797. _areTexturesDirty: boolean;
  55798. }
  55799. /**
  55800. * Define the code related to the sub surface parameters of the pbr material.
  55801. */
  55802. export class PBRSubSurfaceConfiguration {
  55803. private _isRefractionEnabled;
  55804. /**
  55805. * Defines if the refraction is enabled in the material.
  55806. */
  55807. isRefractionEnabled: boolean;
  55808. private _isTranslucencyEnabled;
  55809. /**
  55810. * Defines if the translucency is enabled in the material.
  55811. */
  55812. isTranslucencyEnabled: boolean;
  55813. private _isScatteringEnabled;
  55814. /**
  55815. * Defines if the sub surface scattering is enabled in the material.
  55816. */
  55817. isScatteringEnabled: boolean;
  55818. private _scatteringDiffusionProfileIndex;
  55819. /**
  55820. * Diffusion profile for subsurface scattering.
  55821. * Useful for better scattering in the skins or foliages.
  55822. */
  55823. get scatteringDiffusionProfile(): Nullable<Color3>;
  55824. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55825. /**
  55826. * Defines the refraction intensity of the material.
  55827. * The refraction when enabled replaces the Diffuse part of the material.
  55828. * The intensity helps transitionning between diffuse and refraction.
  55829. */
  55830. refractionIntensity: number;
  55831. /**
  55832. * Defines the translucency intensity of the material.
  55833. * When translucency has been enabled, this defines how much of the "translucency"
  55834. * is addded to the diffuse part of the material.
  55835. */
  55836. translucencyIntensity: number;
  55837. /**
  55838. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55839. */
  55840. useAlbedoToTintRefraction: boolean;
  55841. private _thicknessTexture;
  55842. /**
  55843. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55844. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55845. * 0 would mean minimumThickness
  55846. * 1 would mean maximumThickness
  55847. * The other channels might be use as a mask to vary the different effects intensity.
  55848. */
  55849. thicknessTexture: Nullable<BaseTexture>;
  55850. private _refractionTexture;
  55851. /**
  55852. * Defines the texture to use for refraction.
  55853. */
  55854. refractionTexture: Nullable<BaseTexture>;
  55855. private _indexOfRefraction;
  55856. /**
  55857. * Index of refraction of the material base layer.
  55858. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55859. *
  55860. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55861. *
  55862. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55863. */
  55864. indexOfRefraction: number;
  55865. private _volumeIndexOfRefraction;
  55866. /**
  55867. * Index of refraction of the material's volume.
  55868. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55869. *
  55870. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55871. * the volume will use the same IOR as the surface.
  55872. */
  55873. get volumeIndexOfRefraction(): number;
  55874. set volumeIndexOfRefraction(value: number);
  55875. private _invertRefractionY;
  55876. /**
  55877. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55878. */
  55879. invertRefractionY: boolean;
  55880. private _linkRefractionWithTransparency;
  55881. /**
  55882. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55883. * Materials half opaque for instance using refraction could benefit from this control.
  55884. */
  55885. linkRefractionWithTransparency: boolean;
  55886. /**
  55887. * Defines the minimum thickness stored in the thickness map.
  55888. * If no thickness map is defined, this value will be used to simulate thickness.
  55889. */
  55890. minimumThickness: number;
  55891. /**
  55892. * Defines the maximum thickness stored in the thickness map.
  55893. */
  55894. maximumThickness: number;
  55895. /**
  55896. * Defines the volume tint of the material.
  55897. * This is used for both translucency and scattering.
  55898. */
  55899. tintColor: Color3;
  55900. /**
  55901. * Defines the distance at which the tint color should be found in the media.
  55902. * This is used for refraction only.
  55903. */
  55904. tintColorAtDistance: number;
  55905. /**
  55906. * Defines how far each channel transmit through the media.
  55907. * It is defined as a color to simplify it selection.
  55908. */
  55909. diffusionDistance: Color3;
  55910. private _useMaskFromThicknessTexture;
  55911. /**
  55912. * Stores the intensity of the different subsurface effects in the thickness texture.
  55913. * * the green channel is the translucency intensity.
  55914. * * the blue channel is the scattering intensity.
  55915. * * the alpha channel is the refraction intensity.
  55916. */
  55917. useMaskFromThicknessTexture: boolean;
  55918. private _scene;
  55919. /** @hidden */
  55920. private _internalMarkAllSubMeshesAsTexturesDirty;
  55921. private _internalMarkScenePrePassDirty;
  55922. /** @hidden */
  55923. _markAllSubMeshesAsTexturesDirty(): void;
  55924. /** @hidden */
  55925. _markScenePrePassDirty(): void;
  55926. /**
  55927. * Instantiate a new istance of sub surface configuration.
  55928. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55929. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55930. * @param scene The scene
  55931. */
  55932. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55933. /**
  55934. * Gets wehter the submesh is ready to be used or not.
  55935. * @param defines the list of "defines" to update.
  55936. * @param scene defines the scene the material belongs to.
  55937. * @returns - boolean indicating that the submesh is ready or not.
  55938. */
  55939. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55940. /**
  55941. * Checks to see if a texture is used in the material.
  55942. * @param defines the list of "defines" to update.
  55943. * @param scene defines the scene to the material belongs to.
  55944. */
  55945. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55946. /**
  55947. * Binds the material data.
  55948. * @param uniformBuffer defines the Uniform buffer to fill in.
  55949. * @param scene defines the scene the material belongs to.
  55950. * @param engine defines the engine the material belongs to.
  55951. * @param isFrozen defines whether the material is frozen or not.
  55952. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55953. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55954. */
  55955. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55956. /**
  55957. * Unbinds the material from the mesh.
  55958. * @param activeEffect defines the effect that should be unbound from.
  55959. * @returns true if unbound, otherwise false
  55960. */
  55961. unbind(activeEffect: Effect): boolean;
  55962. /**
  55963. * Returns the texture used for refraction or null if none is used.
  55964. * @param scene defines the scene the material belongs to.
  55965. * @returns - Refraction texture if present. If no refraction texture and refraction
  55966. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55967. */
  55968. private _getRefractionTexture;
  55969. /**
  55970. * Returns true if alpha blending should be disabled.
  55971. */
  55972. get disableAlphaBlending(): boolean;
  55973. /**
  55974. * Fills the list of render target textures.
  55975. * @param renderTargets the list of render targets to update
  55976. */
  55977. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55978. /**
  55979. * Checks to see if a texture is used in the material.
  55980. * @param texture - Base texture to use.
  55981. * @returns - Boolean specifying if a texture is used in the material.
  55982. */
  55983. hasTexture(texture: BaseTexture): boolean;
  55984. /**
  55985. * Gets a boolean indicating that current material needs to register RTT
  55986. * @returns true if this uses a render target otherwise false.
  55987. */
  55988. hasRenderTargetTextures(): boolean;
  55989. /**
  55990. * Returns an array of the actively used textures.
  55991. * @param activeTextures Array of BaseTextures
  55992. */
  55993. getActiveTextures(activeTextures: BaseTexture[]): void;
  55994. /**
  55995. * Returns the animatable textures.
  55996. * @param animatables Array of animatable textures.
  55997. */
  55998. getAnimatables(animatables: IAnimatable[]): void;
  55999. /**
  56000. * Disposes the resources of the material.
  56001. * @param forceDisposeTextures - Forces the disposal of all textures.
  56002. */
  56003. dispose(forceDisposeTextures?: boolean): void;
  56004. /**
  56005. * Get the current class name of the texture useful for serialization or dynamic coding.
  56006. * @returns "PBRSubSurfaceConfiguration"
  56007. */
  56008. getClassName(): string;
  56009. /**
  56010. * Add fallbacks to the effect fallbacks list.
  56011. * @param defines defines the Base texture to use.
  56012. * @param fallbacks defines the current fallback list.
  56013. * @param currentRank defines the current fallback rank.
  56014. * @returns the new fallback rank.
  56015. */
  56016. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56017. /**
  56018. * Add the required uniforms to the current list.
  56019. * @param uniforms defines the current uniform list.
  56020. */
  56021. static AddUniforms(uniforms: string[]): void;
  56022. /**
  56023. * Add the required samplers to the current list.
  56024. * @param samplers defines the current sampler list.
  56025. */
  56026. static AddSamplers(samplers: string[]): void;
  56027. /**
  56028. * Add the required uniforms to the current buffer.
  56029. * @param uniformBuffer defines the current uniform buffer.
  56030. */
  56031. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56032. /**
  56033. * Makes a duplicate of the current configuration into another one.
  56034. * @param configuration define the config where to copy the info
  56035. */
  56036. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56037. /**
  56038. * Serializes this Sub Surface configuration.
  56039. * @returns - An object with the serialized config.
  56040. */
  56041. serialize(): any;
  56042. /**
  56043. * Parses a anisotropy Configuration from a serialized object.
  56044. * @param source - Serialized object.
  56045. * @param scene Defines the scene we are parsing for
  56046. * @param rootUrl Defines the rootUrl to load from
  56047. */
  56048. parse(source: any, scene: Scene, rootUrl: string): void;
  56049. }
  56050. }
  56051. declare module BABYLON {
  56052. /** @hidden */
  56053. export var pbrFragmentDeclaration: {
  56054. name: string;
  56055. shader: string;
  56056. };
  56057. }
  56058. declare module BABYLON {
  56059. /** @hidden */
  56060. export var pbrUboDeclaration: {
  56061. name: string;
  56062. shader: string;
  56063. };
  56064. }
  56065. declare module BABYLON {
  56066. /** @hidden */
  56067. export var pbrFragmentExtraDeclaration: {
  56068. name: string;
  56069. shader: string;
  56070. };
  56071. }
  56072. declare module BABYLON {
  56073. /** @hidden */
  56074. export var pbrFragmentSamplersDeclaration: {
  56075. name: string;
  56076. shader: string;
  56077. };
  56078. }
  56079. declare module BABYLON {
  56080. /** @hidden */
  56081. export var importanceSampling: {
  56082. name: string;
  56083. shader: string;
  56084. };
  56085. }
  56086. declare module BABYLON {
  56087. /** @hidden */
  56088. export var pbrHelperFunctions: {
  56089. name: string;
  56090. shader: string;
  56091. };
  56092. }
  56093. declare module BABYLON {
  56094. /** @hidden */
  56095. export var harmonicsFunctions: {
  56096. name: string;
  56097. shader: string;
  56098. };
  56099. }
  56100. declare module BABYLON {
  56101. /** @hidden */
  56102. export var pbrDirectLightingSetupFunctions: {
  56103. name: string;
  56104. shader: string;
  56105. };
  56106. }
  56107. declare module BABYLON {
  56108. /** @hidden */
  56109. export var pbrDirectLightingFalloffFunctions: {
  56110. name: string;
  56111. shader: string;
  56112. };
  56113. }
  56114. declare module BABYLON {
  56115. /** @hidden */
  56116. export var pbrBRDFFunctions: {
  56117. name: string;
  56118. shader: string;
  56119. };
  56120. }
  56121. declare module BABYLON {
  56122. /** @hidden */
  56123. export var hdrFilteringFunctions: {
  56124. name: string;
  56125. shader: string;
  56126. };
  56127. }
  56128. declare module BABYLON {
  56129. /** @hidden */
  56130. export var pbrDirectLightingFunctions: {
  56131. name: string;
  56132. shader: string;
  56133. };
  56134. }
  56135. declare module BABYLON {
  56136. /** @hidden */
  56137. export var pbrIBLFunctions: {
  56138. name: string;
  56139. shader: string;
  56140. };
  56141. }
  56142. declare module BABYLON {
  56143. /** @hidden */
  56144. export var pbrBlockAlbedoOpacity: {
  56145. name: string;
  56146. shader: string;
  56147. };
  56148. }
  56149. declare module BABYLON {
  56150. /** @hidden */
  56151. export var pbrBlockReflectivity: {
  56152. name: string;
  56153. shader: string;
  56154. };
  56155. }
  56156. declare module BABYLON {
  56157. /** @hidden */
  56158. export var pbrBlockAmbientOcclusion: {
  56159. name: string;
  56160. shader: string;
  56161. };
  56162. }
  56163. declare module BABYLON {
  56164. /** @hidden */
  56165. export var pbrBlockAlphaFresnel: {
  56166. name: string;
  56167. shader: string;
  56168. };
  56169. }
  56170. declare module BABYLON {
  56171. /** @hidden */
  56172. export var pbrBlockAnisotropic: {
  56173. name: string;
  56174. shader: string;
  56175. };
  56176. }
  56177. declare module BABYLON {
  56178. /** @hidden */
  56179. export var pbrBlockReflection: {
  56180. name: string;
  56181. shader: string;
  56182. };
  56183. }
  56184. declare module BABYLON {
  56185. /** @hidden */
  56186. export var pbrBlockSheen: {
  56187. name: string;
  56188. shader: string;
  56189. };
  56190. }
  56191. declare module BABYLON {
  56192. /** @hidden */
  56193. export var pbrBlockClearcoat: {
  56194. name: string;
  56195. shader: string;
  56196. };
  56197. }
  56198. declare module BABYLON {
  56199. /** @hidden */
  56200. export var pbrBlockSubSurface: {
  56201. name: string;
  56202. shader: string;
  56203. };
  56204. }
  56205. declare module BABYLON {
  56206. /** @hidden */
  56207. export var pbrBlockNormalGeometric: {
  56208. name: string;
  56209. shader: string;
  56210. };
  56211. }
  56212. declare module BABYLON {
  56213. /** @hidden */
  56214. export var pbrBlockNormalFinal: {
  56215. name: string;
  56216. shader: string;
  56217. };
  56218. }
  56219. declare module BABYLON {
  56220. /** @hidden */
  56221. export var pbrBlockLightmapInit: {
  56222. name: string;
  56223. shader: string;
  56224. };
  56225. }
  56226. declare module BABYLON {
  56227. /** @hidden */
  56228. export var pbrBlockGeometryInfo: {
  56229. name: string;
  56230. shader: string;
  56231. };
  56232. }
  56233. declare module BABYLON {
  56234. /** @hidden */
  56235. export var pbrBlockReflectance0: {
  56236. name: string;
  56237. shader: string;
  56238. };
  56239. }
  56240. declare module BABYLON {
  56241. /** @hidden */
  56242. export var pbrBlockReflectance: {
  56243. name: string;
  56244. shader: string;
  56245. };
  56246. }
  56247. declare module BABYLON {
  56248. /** @hidden */
  56249. export var pbrBlockDirectLighting: {
  56250. name: string;
  56251. shader: string;
  56252. };
  56253. }
  56254. declare module BABYLON {
  56255. /** @hidden */
  56256. export var pbrBlockFinalLitComponents: {
  56257. name: string;
  56258. shader: string;
  56259. };
  56260. }
  56261. declare module BABYLON {
  56262. /** @hidden */
  56263. export var pbrBlockFinalUnlitComponents: {
  56264. name: string;
  56265. shader: string;
  56266. };
  56267. }
  56268. declare module BABYLON {
  56269. /** @hidden */
  56270. export var pbrBlockFinalColorComposition: {
  56271. name: string;
  56272. shader: string;
  56273. };
  56274. }
  56275. declare module BABYLON {
  56276. /** @hidden */
  56277. export var pbrBlockImageProcessing: {
  56278. name: string;
  56279. shader: string;
  56280. };
  56281. }
  56282. declare module BABYLON {
  56283. /** @hidden */
  56284. export var pbrDebug: {
  56285. name: string;
  56286. shader: string;
  56287. };
  56288. }
  56289. declare module BABYLON {
  56290. /** @hidden */
  56291. export var pbrPixelShader: {
  56292. name: string;
  56293. shader: string;
  56294. };
  56295. }
  56296. declare module BABYLON {
  56297. /** @hidden */
  56298. export var pbrVertexDeclaration: {
  56299. name: string;
  56300. shader: string;
  56301. };
  56302. }
  56303. declare module BABYLON {
  56304. /** @hidden */
  56305. export var pbrVertexShader: {
  56306. name: string;
  56307. shader: string;
  56308. };
  56309. }
  56310. declare module BABYLON {
  56311. /**
  56312. * Manages the defines for the PBR Material.
  56313. * @hidden
  56314. */
  56315. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56316. PBR: boolean;
  56317. NUM_SAMPLES: string;
  56318. REALTIME_FILTERING: boolean;
  56319. MAINUV1: boolean;
  56320. MAINUV2: boolean;
  56321. UV1: boolean;
  56322. UV2: boolean;
  56323. ALBEDO: boolean;
  56324. GAMMAALBEDO: boolean;
  56325. ALBEDODIRECTUV: number;
  56326. VERTEXCOLOR: boolean;
  56327. DETAIL: boolean;
  56328. DETAILDIRECTUV: number;
  56329. DETAIL_NORMALBLENDMETHOD: number;
  56330. AMBIENT: boolean;
  56331. AMBIENTDIRECTUV: number;
  56332. AMBIENTINGRAYSCALE: boolean;
  56333. OPACITY: boolean;
  56334. VERTEXALPHA: boolean;
  56335. OPACITYDIRECTUV: number;
  56336. OPACITYRGB: boolean;
  56337. ALPHATEST: boolean;
  56338. DEPTHPREPASS: boolean;
  56339. ALPHABLEND: boolean;
  56340. ALPHAFROMALBEDO: boolean;
  56341. ALPHATESTVALUE: string;
  56342. SPECULAROVERALPHA: boolean;
  56343. RADIANCEOVERALPHA: boolean;
  56344. ALPHAFRESNEL: boolean;
  56345. LINEARALPHAFRESNEL: boolean;
  56346. PREMULTIPLYALPHA: boolean;
  56347. EMISSIVE: boolean;
  56348. EMISSIVEDIRECTUV: number;
  56349. REFLECTIVITY: boolean;
  56350. REFLECTIVITYDIRECTUV: number;
  56351. SPECULARTERM: boolean;
  56352. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56353. MICROSURFACEAUTOMATIC: boolean;
  56354. LODBASEDMICROSFURACE: boolean;
  56355. MICROSURFACEMAP: boolean;
  56356. MICROSURFACEMAPDIRECTUV: number;
  56357. METALLICWORKFLOW: boolean;
  56358. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56359. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56360. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56361. AOSTOREINMETALMAPRED: boolean;
  56362. METALLIC_REFLECTANCE: boolean;
  56363. METALLIC_REFLECTANCEDIRECTUV: number;
  56364. ENVIRONMENTBRDF: boolean;
  56365. ENVIRONMENTBRDF_RGBD: boolean;
  56366. NORMAL: boolean;
  56367. TANGENT: boolean;
  56368. BUMP: boolean;
  56369. BUMPDIRECTUV: number;
  56370. OBJECTSPACE_NORMALMAP: boolean;
  56371. PARALLAX: boolean;
  56372. PARALLAXOCCLUSION: boolean;
  56373. NORMALXYSCALE: boolean;
  56374. LIGHTMAP: boolean;
  56375. LIGHTMAPDIRECTUV: number;
  56376. USELIGHTMAPASSHADOWMAP: boolean;
  56377. GAMMALIGHTMAP: boolean;
  56378. RGBDLIGHTMAP: boolean;
  56379. REFLECTION: boolean;
  56380. REFLECTIONMAP_3D: boolean;
  56381. REFLECTIONMAP_SPHERICAL: boolean;
  56382. REFLECTIONMAP_PLANAR: boolean;
  56383. REFLECTIONMAP_CUBIC: boolean;
  56384. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56385. REFLECTIONMAP_PROJECTION: boolean;
  56386. REFLECTIONMAP_SKYBOX: boolean;
  56387. REFLECTIONMAP_EXPLICIT: boolean;
  56388. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56389. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56390. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56391. INVERTCUBICMAP: boolean;
  56392. USESPHERICALFROMREFLECTIONMAP: boolean;
  56393. USEIRRADIANCEMAP: boolean;
  56394. SPHERICAL_HARMONICS: boolean;
  56395. USESPHERICALINVERTEX: boolean;
  56396. REFLECTIONMAP_OPPOSITEZ: boolean;
  56397. LODINREFLECTIONALPHA: boolean;
  56398. GAMMAREFLECTION: boolean;
  56399. RGBDREFLECTION: boolean;
  56400. LINEARSPECULARREFLECTION: boolean;
  56401. RADIANCEOCCLUSION: boolean;
  56402. HORIZONOCCLUSION: boolean;
  56403. INSTANCES: boolean;
  56404. THIN_INSTANCES: boolean;
  56405. PREPASS: boolean;
  56406. SCENE_MRT_COUNT: number;
  56407. NUM_BONE_INFLUENCERS: number;
  56408. BonesPerMesh: number;
  56409. BONETEXTURE: boolean;
  56410. NONUNIFORMSCALING: boolean;
  56411. MORPHTARGETS: boolean;
  56412. MORPHTARGETS_NORMAL: boolean;
  56413. MORPHTARGETS_TANGENT: boolean;
  56414. MORPHTARGETS_UV: boolean;
  56415. NUM_MORPH_INFLUENCERS: number;
  56416. IMAGEPROCESSING: boolean;
  56417. VIGNETTE: boolean;
  56418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56419. VIGNETTEBLENDMODEOPAQUE: boolean;
  56420. TONEMAPPING: boolean;
  56421. TONEMAPPING_ACES: boolean;
  56422. CONTRAST: boolean;
  56423. COLORCURVES: boolean;
  56424. COLORGRADING: boolean;
  56425. COLORGRADING3D: boolean;
  56426. SAMPLER3DGREENDEPTH: boolean;
  56427. SAMPLER3DBGRMAP: boolean;
  56428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56429. EXPOSURE: boolean;
  56430. MULTIVIEW: boolean;
  56431. USEPHYSICALLIGHTFALLOFF: boolean;
  56432. USEGLTFLIGHTFALLOFF: boolean;
  56433. TWOSIDEDLIGHTING: boolean;
  56434. SHADOWFLOAT: boolean;
  56435. CLIPPLANE: boolean;
  56436. CLIPPLANE2: boolean;
  56437. CLIPPLANE3: boolean;
  56438. CLIPPLANE4: boolean;
  56439. CLIPPLANE5: boolean;
  56440. CLIPPLANE6: boolean;
  56441. POINTSIZE: boolean;
  56442. FOG: boolean;
  56443. LOGARITHMICDEPTH: boolean;
  56444. FORCENORMALFORWARD: boolean;
  56445. SPECULARAA: boolean;
  56446. CLEARCOAT: boolean;
  56447. CLEARCOAT_DEFAULTIOR: boolean;
  56448. CLEARCOAT_TEXTURE: boolean;
  56449. CLEARCOAT_TEXTUREDIRECTUV: number;
  56450. CLEARCOAT_BUMP: boolean;
  56451. CLEARCOAT_BUMPDIRECTUV: number;
  56452. CLEARCOAT_TINT: boolean;
  56453. CLEARCOAT_TINT_TEXTURE: boolean;
  56454. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56455. ANISOTROPIC: boolean;
  56456. ANISOTROPIC_TEXTURE: boolean;
  56457. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56458. BRDF_V_HEIGHT_CORRELATED: boolean;
  56459. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56460. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56461. SHEEN: boolean;
  56462. SHEEN_TEXTURE: boolean;
  56463. SHEEN_TEXTUREDIRECTUV: number;
  56464. SHEEN_LINKWITHALBEDO: boolean;
  56465. SHEEN_ROUGHNESS: boolean;
  56466. SHEEN_ALBEDOSCALING: boolean;
  56467. SUBSURFACE: boolean;
  56468. SS_REFRACTION: boolean;
  56469. SS_TRANSLUCENCY: boolean;
  56470. SS_SCATTERING: boolean;
  56471. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56472. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56473. SS_REFRACTIONMAP_3D: boolean;
  56474. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56475. SS_LODINREFRACTIONALPHA: boolean;
  56476. SS_GAMMAREFRACTION: boolean;
  56477. SS_RGBDREFRACTION: boolean;
  56478. SS_LINEARSPECULARREFRACTION: boolean;
  56479. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56480. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56481. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56482. UNLIT: boolean;
  56483. DEBUGMODE: number;
  56484. /**
  56485. * Initializes the PBR Material defines.
  56486. */
  56487. constructor();
  56488. /**
  56489. * Resets the PBR Material defines.
  56490. */
  56491. reset(): void;
  56492. }
  56493. /**
  56494. * The Physically based material base class of BJS.
  56495. *
  56496. * This offers the main features of a standard PBR material.
  56497. * For more information, please refer to the documentation :
  56498. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56499. */
  56500. export abstract class PBRBaseMaterial extends PushMaterial {
  56501. /**
  56502. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56503. */
  56504. static readonly PBRMATERIAL_OPAQUE: number;
  56505. /**
  56506. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56507. */
  56508. static readonly PBRMATERIAL_ALPHATEST: number;
  56509. /**
  56510. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56511. */
  56512. static readonly PBRMATERIAL_ALPHABLEND: number;
  56513. /**
  56514. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56515. * They are also discarded below the alpha cutoff threshold to improve performances.
  56516. */
  56517. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56518. /**
  56519. * Defines the default value of how much AO map is occluding the analytical lights
  56520. * (point spot...).
  56521. */
  56522. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56523. /**
  56524. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56525. */
  56526. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56527. /**
  56528. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56529. * to enhance interoperability with other engines.
  56530. */
  56531. static readonly LIGHTFALLOFF_GLTF: number;
  56532. /**
  56533. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56534. * to enhance interoperability with other materials.
  56535. */
  56536. static readonly LIGHTFALLOFF_STANDARD: number;
  56537. /**
  56538. * Intensity of the direct lights e.g. the four lights available in your scene.
  56539. * This impacts both the direct diffuse and specular highlights.
  56540. */
  56541. protected _directIntensity: number;
  56542. /**
  56543. * Intensity of the emissive part of the material.
  56544. * This helps controlling the emissive effect without modifying the emissive color.
  56545. */
  56546. protected _emissiveIntensity: number;
  56547. /**
  56548. * Intensity of the environment e.g. how much the environment will light the object
  56549. * either through harmonics for rough material or through the refelction for shiny ones.
  56550. */
  56551. protected _environmentIntensity: number;
  56552. /**
  56553. * This is a special control allowing the reduction of the specular highlights coming from the
  56554. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56555. */
  56556. protected _specularIntensity: number;
  56557. /**
  56558. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56559. */
  56560. private _lightingInfos;
  56561. /**
  56562. * Debug Control allowing disabling the bump map on this material.
  56563. */
  56564. protected _disableBumpMap: boolean;
  56565. /**
  56566. * AKA Diffuse Texture in standard nomenclature.
  56567. */
  56568. protected _albedoTexture: Nullable<BaseTexture>;
  56569. /**
  56570. * AKA Occlusion Texture in other nomenclature.
  56571. */
  56572. protected _ambientTexture: Nullable<BaseTexture>;
  56573. /**
  56574. * AKA Occlusion Texture Intensity in other nomenclature.
  56575. */
  56576. protected _ambientTextureStrength: number;
  56577. /**
  56578. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56579. * 1 means it completely occludes it
  56580. * 0 mean it has no impact
  56581. */
  56582. protected _ambientTextureImpactOnAnalyticalLights: number;
  56583. /**
  56584. * Stores the alpha values in a texture.
  56585. */
  56586. protected _opacityTexture: Nullable<BaseTexture>;
  56587. /**
  56588. * Stores the reflection values in a texture.
  56589. */
  56590. protected _reflectionTexture: Nullable<BaseTexture>;
  56591. /**
  56592. * Stores the emissive values in a texture.
  56593. */
  56594. protected _emissiveTexture: Nullable<BaseTexture>;
  56595. /**
  56596. * AKA Specular texture in other nomenclature.
  56597. */
  56598. protected _reflectivityTexture: Nullable<BaseTexture>;
  56599. /**
  56600. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56601. */
  56602. protected _metallicTexture: Nullable<BaseTexture>;
  56603. /**
  56604. * Specifies the metallic scalar of the metallic/roughness workflow.
  56605. * Can also be used to scale the metalness values of the metallic texture.
  56606. */
  56607. protected _metallic: Nullable<number>;
  56608. /**
  56609. * Specifies the roughness scalar of the metallic/roughness workflow.
  56610. * Can also be used to scale the roughness values of the metallic texture.
  56611. */
  56612. protected _roughness: Nullable<number>;
  56613. /**
  56614. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56615. * By default the indexOfrefraction is used to compute F0;
  56616. *
  56617. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56618. *
  56619. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56620. * F90 = metallicReflectanceColor;
  56621. */
  56622. protected _metallicF0Factor: number;
  56623. /**
  56624. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56625. * By default the F90 is always 1;
  56626. *
  56627. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56628. *
  56629. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56630. * F90 = metallicReflectanceColor;
  56631. */
  56632. protected _metallicReflectanceColor: Color3;
  56633. /**
  56634. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56635. * This is multiply against the scalar values defined in the material.
  56636. */
  56637. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56638. /**
  56639. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56640. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56641. */
  56642. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56643. /**
  56644. * Stores surface normal data used to displace a mesh in a texture.
  56645. */
  56646. protected _bumpTexture: Nullable<BaseTexture>;
  56647. /**
  56648. * Stores the pre-calculated light information of a mesh in a texture.
  56649. */
  56650. protected _lightmapTexture: Nullable<BaseTexture>;
  56651. /**
  56652. * The color of a material in ambient lighting.
  56653. */
  56654. protected _ambientColor: Color3;
  56655. /**
  56656. * AKA Diffuse Color in other nomenclature.
  56657. */
  56658. protected _albedoColor: Color3;
  56659. /**
  56660. * AKA Specular Color in other nomenclature.
  56661. */
  56662. protected _reflectivityColor: Color3;
  56663. /**
  56664. * The color applied when light is reflected from a material.
  56665. */
  56666. protected _reflectionColor: Color3;
  56667. /**
  56668. * The color applied when light is emitted from a material.
  56669. */
  56670. protected _emissiveColor: Color3;
  56671. /**
  56672. * AKA Glossiness in other nomenclature.
  56673. */
  56674. protected _microSurface: number;
  56675. /**
  56676. * Specifies that the material will use the light map as a show map.
  56677. */
  56678. protected _useLightmapAsShadowmap: boolean;
  56679. /**
  56680. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56681. * makes the reflect vector face the model (under horizon).
  56682. */
  56683. protected _useHorizonOcclusion: boolean;
  56684. /**
  56685. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56686. * too much the area relying on ambient texture to define their ambient occlusion.
  56687. */
  56688. protected _useRadianceOcclusion: boolean;
  56689. /**
  56690. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56691. */
  56692. protected _useAlphaFromAlbedoTexture: boolean;
  56693. /**
  56694. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56695. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56696. */
  56697. protected _useSpecularOverAlpha: boolean;
  56698. /**
  56699. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56700. */
  56701. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56702. /**
  56703. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56704. */
  56705. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56706. /**
  56707. * Specifies if the metallic texture contains the roughness information in its green channel.
  56708. */
  56709. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56710. /**
  56711. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56712. */
  56713. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56714. /**
  56715. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56716. */
  56717. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56718. /**
  56719. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56720. */
  56721. protected _useAmbientInGrayScale: boolean;
  56722. /**
  56723. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56724. * The material will try to infer what glossiness each pixel should be.
  56725. */
  56726. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56727. /**
  56728. * Defines the falloff type used in this material.
  56729. * It by default is Physical.
  56730. */
  56731. protected _lightFalloff: number;
  56732. /**
  56733. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56734. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56735. */
  56736. protected _useRadianceOverAlpha: boolean;
  56737. /**
  56738. * Allows using an object space normal map (instead of tangent space).
  56739. */
  56740. protected _useObjectSpaceNormalMap: boolean;
  56741. /**
  56742. * Allows using the bump map in parallax mode.
  56743. */
  56744. protected _useParallax: boolean;
  56745. /**
  56746. * Allows using the bump map in parallax occlusion mode.
  56747. */
  56748. protected _useParallaxOcclusion: boolean;
  56749. /**
  56750. * Controls the scale bias of the parallax mode.
  56751. */
  56752. protected _parallaxScaleBias: number;
  56753. /**
  56754. * If sets to true, disables all the lights affecting the material.
  56755. */
  56756. protected _disableLighting: boolean;
  56757. /**
  56758. * Number of Simultaneous lights allowed on the material.
  56759. */
  56760. protected _maxSimultaneousLights: number;
  56761. /**
  56762. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56763. */
  56764. protected _invertNormalMapX: boolean;
  56765. /**
  56766. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56767. */
  56768. protected _invertNormalMapY: boolean;
  56769. /**
  56770. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56771. */
  56772. protected _twoSidedLighting: boolean;
  56773. /**
  56774. * Defines the alpha limits in alpha test mode.
  56775. */
  56776. protected _alphaCutOff: number;
  56777. /**
  56778. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56779. */
  56780. protected _forceAlphaTest: boolean;
  56781. /**
  56782. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56783. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56784. */
  56785. protected _useAlphaFresnel: boolean;
  56786. /**
  56787. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56788. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56789. */
  56790. protected _useLinearAlphaFresnel: boolean;
  56791. /**
  56792. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56793. * from cos thetav and roughness:
  56794. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56795. */
  56796. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56797. /**
  56798. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56799. */
  56800. protected _forceIrradianceInFragment: boolean;
  56801. private _realTimeFiltering;
  56802. /**
  56803. * Enables realtime filtering on the texture.
  56804. */
  56805. get realTimeFiltering(): boolean;
  56806. set realTimeFiltering(b: boolean);
  56807. private _realTimeFilteringQuality;
  56808. /**
  56809. * Quality switch for realtime filtering
  56810. */
  56811. get realTimeFilteringQuality(): number;
  56812. set realTimeFilteringQuality(n: number);
  56813. /**
  56814. * Can this material render to several textures at once
  56815. */
  56816. get canRenderToMRT(): boolean;
  56817. /**
  56818. * Force normal to face away from face.
  56819. */
  56820. protected _forceNormalForward: boolean;
  56821. /**
  56822. * Enables specular anti aliasing in the PBR shader.
  56823. * It will both interacts on the Geometry for analytical and IBL lighting.
  56824. * It also prefilter the roughness map based on the bump values.
  56825. */
  56826. protected _enableSpecularAntiAliasing: boolean;
  56827. /**
  56828. * Default configuration related to image processing available in the PBR Material.
  56829. */
  56830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56831. /**
  56832. * Keep track of the image processing observer to allow dispose and replace.
  56833. */
  56834. private _imageProcessingObserver;
  56835. /**
  56836. * Attaches a new image processing configuration to the PBR Material.
  56837. * @param configuration
  56838. */
  56839. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56840. /**
  56841. * Stores the available render targets.
  56842. */
  56843. private _renderTargets;
  56844. /**
  56845. * Sets the global ambient color for the material used in lighting calculations.
  56846. */
  56847. private _globalAmbientColor;
  56848. /**
  56849. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56850. */
  56851. private _useLogarithmicDepth;
  56852. /**
  56853. * If set to true, no lighting calculations will be applied.
  56854. */
  56855. private _unlit;
  56856. private _debugMode;
  56857. /**
  56858. * @hidden
  56859. * This is reserved for the inspector.
  56860. * Defines the material debug mode.
  56861. * It helps seeing only some components of the material while troubleshooting.
  56862. */
  56863. debugMode: number;
  56864. /**
  56865. * @hidden
  56866. * This is reserved for the inspector.
  56867. * Specify from where on screen the debug mode should start.
  56868. * The value goes from -1 (full screen) to 1 (not visible)
  56869. * It helps with side by side comparison against the final render
  56870. * This defaults to -1
  56871. */
  56872. private debugLimit;
  56873. /**
  56874. * @hidden
  56875. * This is reserved for the inspector.
  56876. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56877. * You can use the factor to better multiply the final value.
  56878. */
  56879. private debugFactor;
  56880. /**
  56881. * Defines the clear coat layer parameters for the material.
  56882. */
  56883. readonly clearCoat: PBRClearCoatConfiguration;
  56884. /**
  56885. * Defines the anisotropic parameters for the material.
  56886. */
  56887. readonly anisotropy: PBRAnisotropicConfiguration;
  56888. /**
  56889. * Defines the BRDF parameters for the material.
  56890. */
  56891. readonly brdf: PBRBRDFConfiguration;
  56892. /**
  56893. * Defines the Sheen parameters for the material.
  56894. */
  56895. readonly sheen: PBRSheenConfiguration;
  56896. /**
  56897. * Defines the SubSurface parameters for the material.
  56898. */
  56899. readonly subSurface: PBRSubSurfaceConfiguration;
  56900. /**
  56901. * Defines the detail map parameters for the material.
  56902. */
  56903. readonly detailMap: DetailMapConfiguration;
  56904. protected _rebuildInParallel: boolean;
  56905. /**
  56906. * Instantiates a new PBRMaterial instance.
  56907. *
  56908. * @param name The material name
  56909. * @param scene The scene the material will be use in.
  56910. */
  56911. constructor(name: string, scene: Scene);
  56912. /**
  56913. * Gets a boolean indicating that current material needs to register RTT
  56914. */
  56915. get hasRenderTargetTextures(): boolean;
  56916. /**
  56917. * Gets the name of the material class.
  56918. */
  56919. getClassName(): string;
  56920. /**
  56921. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56922. */
  56923. get useLogarithmicDepth(): boolean;
  56924. /**
  56925. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56926. */
  56927. set useLogarithmicDepth(value: boolean);
  56928. /**
  56929. * Returns true if alpha blending should be disabled.
  56930. */
  56931. protected get _disableAlphaBlending(): boolean;
  56932. /**
  56933. * Specifies whether or not this material should be rendered in alpha blend mode.
  56934. */
  56935. needAlphaBlending(): boolean;
  56936. /**
  56937. * Specifies whether or not this material should be rendered in alpha test mode.
  56938. */
  56939. needAlphaTesting(): boolean;
  56940. /**
  56941. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56942. */
  56943. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56944. /**
  56945. * Gets the texture used for the alpha test.
  56946. */
  56947. getAlphaTestTexture(): Nullable<BaseTexture>;
  56948. /**
  56949. * Specifies that the submesh is ready to be used.
  56950. * @param mesh - BJS mesh.
  56951. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56952. * @param useInstances - Specifies that instances should be used.
  56953. * @returns - boolean indicating that the submesh is ready or not.
  56954. */
  56955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56956. /**
  56957. * Specifies if the material uses metallic roughness workflow.
  56958. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56959. */
  56960. isMetallicWorkflow(): boolean;
  56961. private _prepareEffect;
  56962. private _prepareDefines;
  56963. /**
  56964. * Force shader compilation
  56965. */
  56966. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56967. /**
  56968. * Initializes the uniform buffer layout for the shader.
  56969. */
  56970. buildUniformLayout(): void;
  56971. /**
  56972. * Unbinds the material from the mesh
  56973. */
  56974. unbind(): void;
  56975. /**
  56976. * Binds the submesh data.
  56977. * @param world - The world matrix.
  56978. * @param mesh - The BJS mesh.
  56979. * @param subMesh - A submesh of the BJS mesh.
  56980. */
  56981. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56982. /**
  56983. * Returns the animatable textures.
  56984. * @returns - Array of animatable textures.
  56985. */
  56986. getAnimatables(): IAnimatable[];
  56987. /**
  56988. * Returns the texture used for reflections.
  56989. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56990. */
  56991. private _getReflectionTexture;
  56992. /**
  56993. * Returns an array of the actively used textures.
  56994. * @returns - Array of BaseTextures
  56995. */
  56996. getActiveTextures(): BaseTexture[];
  56997. /**
  56998. * Checks to see if a texture is used in the material.
  56999. * @param texture - Base texture to use.
  57000. * @returns - Boolean specifying if a texture is used in the material.
  57001. */
  57002. hasTexture(texture: BaseTexture): boolean;
  57003. /**
  57004. * Sets the required values to the prepass renderer.
  57005. * @param prePassRenderer defines the prepass renderer to setup
  57006. */
  57007. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57008. /**
  57009. * Disposes the resources of the material.
  57010. * @param forceDisposeEffect - Forces the disposal of effects.
  57011. * @param forceDisposeTextures - Forces the disposal of all textures.
  57012. */
  57013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57014. }
  57015. }
  57016. declare module BABYLON {
  57017. /**
  57018. * The Physically based material of BJS.
  57019. *
  57020. * This offers the main features of a standard PBR material.
  57021. * For more information, please refer to the documentation :
  57022. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57023. */
  57024. export class PBRMaterial extends PBRBaseMaterial {
  57025. /**
  57026. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57027. */
  57028. static readonly PBRMATERIAL_OPAQUE: number;
  57029. /**
  57030. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57031. */
  57032. static readonly PBRMATERIAL_ALPHATEST: number;
  57033. /**
  57034. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57035. */
  57036. static readonly PBRMATERIAL_ALPHABLEND: number;
  57037. /**
  57038. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57039. * They are also discarded below the alpha cutoff threshold to improve performances.
  57040. */
  57041. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57042. /**
  57043. * Defines the default value of how much AO map is occluding the analytical lights
  57044. * (point spot...).
  57045. */
  57046. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57047. /**
  57048. * Intensity of the direct lights e.g. the four lights available in your scene.
  57049. * This impacts both the direct diffuse and specular highlights.
  57050. */
  57051. directIntensity: number;
  57052. /**
  57053. * Intensity of the emissive part of the material.
  57054. * This helps controlling the emissive effect without modifying the emissive color.
  57055. */
  57056. emissiveIntensity: number;
  57057. /**
  57058. * Intensity of the environment e.g. how much the environment will light the object
  57059. * either through harmonics for rough material or through the refelction for shiny ones.
  57060. */
  57061. environmentIntensity: number;
  57062. /**
  57063. * This is a special control allowing the reduction of the specular highlights coming from the
  57064. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57065. */
  57066. specularIntensity: number;
  57067. /**
  57068. * Debug Control allowing disabling the bump map on this material.
  57069. */
  57070. disableBumpMap: boolean;
  57071. /**
  57072. * AKA Diffuse Texture in standard nomenclature.
  57073. */
  57074. albedoTexture: BaseTexture;
  57075. /**
  57076. * AKA Occlusion Texture in other nomenclature.
  57077. */
  57078. ambientTexture: BaseTexture;
  57079. /**
  57080. * AKA Occlusion Texture Intensity in other nomenclature.
  57081. */
  57082. ambientTextureStrength: number;
  57083. /**
  57084. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57085. * 1 means it completely occludes it
  57086. * 0 mean it has no impact
  57087. */
  57088. ambientTextureImpactOnAnalyticalLights: number;
  57089. /**
  57090. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57091. */
  57092. opacityTexture: BaseTexture;
  57093. /**
  57094. * Stores the reflection values in a texture.
  57095. */
  57096. reflectionTexture: Nullable<BaseTexture>;
  57097. /**
  57098. * Stores the emissive values in a texture.
  57099. */
  57100. emissiveTexture: BaseTexture;
  57101. /**
  57102. * AKA Specular texture in other nomenclature.
  57103. */
  57104. reflectivityTexture: BaseTexture;
  57105. /**
  57106. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57107. */
  57108. metallicTexture: BaseTexture;
  57109. /**
  57110. * Specifies the metallic scalar of the metallic/roughness workflow.
  57111. * Can also be used to scale the metalness values of the metallic texture.
  57112. */
  57113. metallic: Nullable<number>;
  57114. /**
  57115. * Specifies the roughness scalar of the metallic/roughness workflow.
  57116. * Can also be used to scale the roughness values of the metallic texture.
  57117. */
  57118. roughness: Nullable<number>;
  57119. /**
  57120. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57121. * By default the indexOfrefraction is used to compute F0;
  57122. *
  57123. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57124. *
  57125. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57126. * F90 = metallicReflectanceColor;
  57127. */
  57128. metallicF0Factor: number;
  57129. /**
  57130. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57131. * By default the F90 is always 1;
  57132. *
  57133. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57134. *
  57135. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57136. * F90 = metallicReflectanceColor;
  57137. */
  57138. metallicReflectanceColor: Color3;
  57139. /**
  57140. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57141. * This is multiply against the scalar values defined in the material.
  57142. */
  57143. metallicReflectanceTexture: Nullable<BaseTexture>;
  57144. /**
  57145. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57146. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57147. */
  57148. microSurfaceTexture: BaseTexture;
  57149. /**
  57150. * Stores surface normal data used to displace a mesh in a texture.
  57151. */
  57152. bumpTexture: BaseTexture;
  57153. /**
  57154. * Stores the pre-calculated light information of a mesh in a texture.
  57155. */
  57156. lightmapTexture: BaseTexture;
  57157. /**
  57158. * Stores the refracted light information in a texture.
  57159. */
  57160. get refractionTexture(): Nullable<BaseTexture>;
  57161. set refractionTexture(value: Nullable<BaseTexture>);
  57162. /**
  57163. * The color of a material in ambient lighting.
  57164. */
  57165. ambientColor: Color3;
  57166. /**
  57167. * AKA Diffuse Color in other nomenclature.
  57168. */
  57169. albedoColor: Color3;
  57170. /**
  57171. * AKA Specular Color in other nomenclature.
  57172. */
  57173. reflectivityColor: Color3;
  57174. /**
  57175. * The color reflected from the material.
  57176. */
  57177. reflectionColor: Color3;
  57178. /**
  57179. * The color emitted from the material.
  57180. */
  57181. emissiveColor: Color3;
  57182. /**
  57183. * AKA Glossiness in other nomenclature.
  57184. */
  57185. microSurface: number;
  57186. /**
  57187. * Index of refraction of the material base layer.
  57188. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57189. *
  57190. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57191. *
  57192. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57193. */
  57194. get indexOfRefraction(): number;
  57195. set indexOfRefraction(value: number);
  57196. /**
  57197. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57198. */
  57199. get invertRefractionY(): boolean;
  57200. set invertRefractionY(value: boolean);
  57201. /**
  57202. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57203. * Materials half opaque for instance using refraction could benefit from this control.
  57204. */
  57205. get linkRefractionWithTransparency(): boolean;
  57206. set linkRefractionWithTransparency(value: boolean);
  57207. /**
  57208. * If true, the light map contains occlusion information instead of lighting info.
  57209. */
  57210. useLightmapAsShadowmap: boolean;
  57211. /**
  57212. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57213. */
  57214. useAlphaFromAlbedoTexture: boolean;
  57215. /**
  57216. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57217. */
  57218. forceAlphaTest: boolean;
  57219. /**
  57220. * Defines the alpha limits in alpha test mode.
  57221. */
  57222. alphaCutOff: number;
  57223. /**
  57224. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57225. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57226. */
  57227. useSpecularOverAlpha: boolean;
  57228. /**
  57229. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57230. */
  57231. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57232. /**
  57233. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57234. */
  57235. useRoughnessFromMetallicTextureAlpha: boolean;
  57236. /**
  57237. * Specifies if the metallic texture contains the roughness information in its green channel.
  57238. */
  57239. useRoughnessFromMetallicTextureGreen: boolean;
  57240. /**
  57241. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57242. */
  57243. useMetallnessFromMetallicTextureBlue: boolean;
  57244. /**
  57245. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57246. */
  57247. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57248. /**
  57249. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57250. */
  57251. useAmbientInGrayScale: boolean;
  57252. /**
  57253. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57254. * The material will try to infer what glossiness each pixel should be.
  57255. */
  57256. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57257. /**
  57258. * BJS is using an harcoded light falloff based on a manually sets up range.
  57259. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57260. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57261. */
  57262. get usePhysicalLightFalloff(): boolean;
  57263. /**
  57264. * BJS is using an harcoded light falloff based on a manually sets up range.
  57265. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57266. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57267. */
  57268. set usePhysicalLightFalloff(value: boolean);
  57269. /**
  57270. * In order to support the falloff compatibility with gltf, a special mode has been added
  57271. * to reproduce the gltf light falloff.
  57272. */
  57273. get useGLTFLightFalloff(): boolean;
  57274. /**
  57275. * In order to support the falloff compatibility with gltf, a special mode has been added
  57276. * to reproduce the gltf light falloff.
  57277. */
  57278. set useGLTFLightFalloff(value: boolean);
  57279. /**
  57280. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57281. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57282. */
  57283. useRadianceOverAlpha: boolean;
  57284. /**
  57285. * Allows using an object space normal map (instead of tangent space).
  57286. */
  57287. useObjectSpaceNormalMap: boolean;
  57288. /**
  57289. * Allows using the bump map in parallax mode.
  57290. */
  57291. useParallax: boolean;
  57292. /**
  57293. * Allows using the bump map in parallax occlusion mode.
  57294. */
  57295. useParallaxOcclusion: boolean;
  57296. /**
  57297. * Controls the scale bias of the parallax mode.
  57298. */
  57299. parallaxScaleBias: number;
  57300. /**
  57301. * If sets to true, disables all the lights affecting the material.
  57302. */
  57303. disableLighting: boolean;
  57304. /**
  57305. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57306. */
  57307. forceIrradianceInFragment: boolean;
  57308. /**
  57309. * Number of Simultaneous lights allowed on the material.
  57310. */
  57311. maxSimultaneousLights: number;
  57312. /**
  57313. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57314. */
  57315. invertNormalMapX: boolean;
  57316. /**
  57317. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57318. */
  57319. invertNormalMapY: boolean;
  57320. /**
  57321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57322. */
  57323. twoSidedLighting: boolean;
  57324. /**
  57325. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57326. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57327. */
  57328. useAlphaFresnel: boolean;
  57329. /**
  57330. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57331. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57332. */
  57333. useLinearAlphaFresnel: boolean;
  57334. /**
  57335. * Let user defines the brdf lookup texture used for IBL.
  57336. * A default 8bit version is embedded but you could point at :
  57337. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57338. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57339. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57340. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57341. */
  57342. environmentBRDFTexture: Nullable<BaseTexture>;
  57343. /**
  57344. * Force normal to face away from face.
  57345. */
  57346. forceNormalForward: boolean;
  57347. /**
  57348. * Enables specular anti aliasing in the PBR shader.
  57349. * It will both interacts on the Geometry for analytical and IBL lighting.
  57350. * It also prefilter the roughness map based on the bump values.
  57351. */
  57352. enableSpecularAntiAliasing: boolean;
  57353. /**
  57354. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57355. * makes the reflect vector face the model (under horizon).
  57356. */
  57357. useHorizonOcclusion: boolean;
  57358. /**
  57359. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57360. * too much the area relying on ambient texture to define their ambient occlusion.
  57361. */
  57362. useRadianceOcclusion: boolean;
  57363. /**
  57364. * If set to true, no lighting calculations will be applied.
  57365. */
  57366. unlit: boolean;
  57367. /**
  57368. * Gets the image processing configuration used either in this material.
  57369. */
  57370. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57371. /**
  57372. * Sets the Default image processing configuration used either in the this material.
  57373. *
  57374. * If sets to null, the scene one is in use.
  57375. */
  57376. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57377. /**
  57378. * Gets wether the color curves effect is enabled.
  57379. */
  57380. get cameraColorCurvesEnabled(): boolean;
  57381. /**
  57382. * Sets wether the color curves effect is enabled.
  57383. */
  57384. set cameraColorCurvesEnabled(value: boolean);
  57385. /**
  57386. * Gets wether the color grading effect is enabled.
  57387. */
  57388. get cameraColorGradingEnabled(): boolean;
  57389. /**
  57390. * Gets wether the color grading effect is enabled.
  57391. */
  57392. set cameraColorGradingEnabled(value: boolean);
  57393. /**
  57394. * Gets wether tonemapping is enabled or not.
  57395. */
  57396. get cameraToneMappingEnabled(): boolean;
  57397. /**
  57398. * Sets wether tonemapping is enabled or not
  57399. */
  57400. set cameraToneMappingEnabled(value: boolean);
  57401. /**
  57402. * The camera exposure used on this material.
  57403. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57404. * This corresponds to a photographic exposure.
  57405. */
  57406. get cameraExposure(): number;
  57407. /**
  57408. * The camera exposure used on this material.
  57409. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57410. * This corresponds to a photographic exposure.
  57411. */
  57412. set cameraExposure(value: number);
  57413. /**
  57414. * Gets The camera contrast used on this material.
  57415. */
  57416. get cameraContrast(): number;
  57417. /**
  57418. * Sets The camera contrast used on this material.
  57419. */
  57420. set cameraContrast(value: number);
  57421. /**
  57422. * Gets the Color Grading 2D Lookup Texture.
  57423. */
  57424. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57425. /**
  57426. * Sets the Color Grading 2D Lookup Texture.
  57427. */
  57428. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57429. /**
  57430. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57431. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57432. * 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;
  57433. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57434. */
  57435. get cameraColorCurves(): Nullable<ColorCurves>;
  57436. /**
  57437. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57438. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57439. * 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;
  57440. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57441. */
  57442. set cameraColorCurves(value: Nullable<ColorCurves>);
  57443. /**
  57444. * Instantiates a new PBRMaterial instance.
  57445. *
  57446. * @param name The material name
  57447. * @param scene The scene the material will be use in.
  57448. */
  57449. constructor(name: string, scene: Scene);
  57450. /**
  57451. * Returns the name of this material class.
  57452. */
  57453. getClassName(): string;
  57454. /**
  57455. * Makes a duplicate of the current material.
  57456. * @param name - name to use for the new material.
  57457. */
  57458. clone(name: string): PBRMaterial;
  57459. /**
  57460. * Serializes this PBR Material.
  57461. * @returns - An object with the serialized material.
  57462. */
  57463. serialize(): any;
  57464. /**
  57465. * Parses a PBR Material from a serialized object.
  57466. * @param source - Serialized object.
  57467. * @param scene - BJS scene instance.
  57468. * @param rootUrl - url for the scene object
  57469. * @returns - PBRMaterial
  57470. */
  57471. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57472. }
  57473. }
  57474. declare module BABYLON {
  57475. /**
  57476. * Direct draw surface info
  57477. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57478. */
  57479. export interface DDSInfo {
  57480. /**
  57481. * Width of the texture
  57482. */
  57483. width: number;
  57484. /**
  57485. * Width of the texture
  57486. */
  57487. height: number;
  57488. /**
  57489. * Number of Mipmaps for the texture
  57490. * @see https://en.wikipedia.org/wiki/Mipmap
  57491. */
  57492. mipmapCount: number;
  57493. /**
  57494. * If the textures format is a known fourCC format
  57495. * @see https://www.fourcc.org/
  57496. */
  57497. isFourCC: boolean;
  57498. /**
  57499. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57500. */
  57501. isRGB: boolean;
  57502. /**
  57503. * If the texture is a lumincance format
  57504. */
  57505. isLuminance: boolean;
  57506. /**
  57507. * If this is a cube texture
  57508. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57509. */
  57510. isCube: boolean;
  57511. /**
  57512. * If the texture is a compressed format eg. FOURCC_DXT1
  57513. */
  57514. isCompressed: boolean;
  57515. /**
  57516. * The dxgiFormat of the texture
  57517. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57518. */
  57519. dxgiFormat: number;
  57520. /**
  57521. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57522. */
  57523. textureType: number;
  57524. /**
  57525. * Sphericle polynomial created for the dds texture
  57526. */
  57527. sphericalPolynomial?: SphericalPolynomial;
  57528. }
  57529. /**
  57530. * Class used to provide DDS decompression tools
  57531. */
  57532. export class DDSTools {
  57533. /**
  57534. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57535. */
  57536. static StoreLODInAlphaChannel: boolean;
  57537. /**
  57538. * Gets DDS information from an array buffer
  57539. * @param data defines the array buffer view to read data from
  57540. * @returns the DDS information
  57541. */
  57542. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57543. private static _FloatView;
  57544. private static _Int32View;
  57545. private static _ToHalfFloat;
  57546. private static _FromHalfFloat;
  57547. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57548. private static _GetHalfFloatRGBAArrayBuffer;
  57549. private static _GetFloatRGBAArrayBuffer;
  57550. private static _GetFloatAsUIntRGBAArrayBuffer;
  57551. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57552. private static _GetRGBAArrayBuffer;
  57553. private static _ExtractLongWordOrder;
  57554. private static _GetRGBArrayBuffer;
  57555. private static _GetLuminanceArrayBuffer;
  57556. /**
  57557. * Uploads DDS Levels to a Babylon Texture
  57558. * @hidden
  57559. */
  57560. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57561. }
  57562. interface ThinEngine {
  57563. /**
  57564. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57565. * @param rootUrl defines the url where the file to load is located
  57566. * @param scene defines the current scene
  57567. * @param lodScale defines scale to apply to the mip map selection
  57568. * @param lodOffset defines offset to apply to the mip map selection
  57569. * @param onLoad defines an optional callback raised when the texture is loaded
  57570. * @param onError defines an optional callback raised if there is an issue to load the texture
  57571. * @param format defines the format of the data
  57572. * @param forcedExtension defines the extension to use to pick the right loader
  57573. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57574. * @returns the cube texture as an InternalTexture
  57575. */
  57576. 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;
  57577. }
  57578. }
  57579. declare module BABYLON {
  57580. /**
  57581. * Implementation of the DDS Texture Loader.
  57582. * @hidden
  57583. */
  57584. export class _DDSTextureLoader implements IInternalTextureLoader {
  57585. /**
  57586. * Defines wether the loader supports cascade loading the different faces.
  57587. */
  57588. readonly supportCascades: boolean;
  57589. /**
  57590. * This returns if the loader support the current file information.
  57591. * @param extension defines the file extension of the file being loaded
  57592. * @returns true if the loader can load the specified file
  57593. */
  57594. canLoad(extension: string): boolean;
  57595. /**
  57596. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57597. * @param data contains the texture data
  57598. * @param texture defines the BabylonJS internal texture
  57599. * @param createPolynomials will be true if polynomials have been requested
  57600. * @param onLoad defines the callback to trigger once the texture is ready
  57601. * @param onError defines the callback to trigger in case of error
  57602. */
  57603. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57604. /**
  57605. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57606. * @param data contains the texture data
  57607. * @param texture defines the BabylonJS internal texture
  57608. * @param callback defines the method to call once ready to upload
  57609. */
  57610. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57611. }
  57612. }
  57613. declare module BABYLON {
  57614. /**
  57615. * Implementation of the ENV Texture Loader.
  57616. * @hidden
  57617. */
  57618. export class _ENVTextureLoader implements IInternalTextureLoader {
  57619. /**
  57620. * Defines wether the loader supports cascade loading the different faces.
  57621. */
  57622. readonly supportCascades: boolean;
  57623. /**
  57624. * This returns if the loader support the current file information.
  57625. * @param extension defines the file extension of the file being loaded
  57626. * @returns true if the loader can load the specified file
  57627. */
  57628. canLoad(extension: string): boolean;
  57629. /**
  57630. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57631. * @param data contains the texture data
  57632. * @param texture defines the BabylonJS internal texture
  57633. * @param createPolynomials will be true if polynomials have been requested
  57634. * @param onLoad defines the callback to trigger once the texture is ready
  57635. * @param onError defines the callback to trigger in case of error
  57636. */
  57637. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57638. /**
  57639. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57640. * @param data contains the texture data
  57641. * @param texture defines the BabylonJS internal texture
  57642. * @param callback defines the method to call once ready to upload
  57643. */
  57644. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57645. }
  57646. }
  57647. declare module BABYLON {
  57648. /**
  57649. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57650. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57651. */
  57652. export class KhronosTextureContainer {
  57653. /** contents of the KTX container file */
  57654. data: ArrayBufferView;
  57655. private static HEADER_LEN;
  57656. private static COMPRESSED_2D;
  57657. private static COMPRESSED_3D;
  57658. private static TEX_2D;
  57659. private static TEX_3D;
  57660. /**
  57661. * Gets the openGL type
  57662. */
  57663. glType: number;
  57664. /**
  57665. * Gets the openGL type size
  57666. */
  57667. glTypeSize: number;
  57668. /**
  57669. * Gets the openGL format
  57670. */
  57671. glFormat: number;
  57672. /**
  57673. * Gets the openGL internal format
  57674. */
  57675. glInternalFormat: number;
  57676. /**
  57677. * Gets the base internal format
  57678. */
  57679. glBaseInternalFormat: number;
  57680. /**
  57681. * Gets image width in pixel
  57682. */
  57683. pixelWidth: number;
  57684. /**
  57685. * Gets image height in pixel
  57686. */
  57687. pixelHeight: number;
  57688. /**
  57689. * Gets image depth in pixels
  57690. */
  57691. pixelDepth: number;
  57692. /**
  57693. * Gets the number of array elements
  57694. */
  57695. numberOfArrayElements: number;
  57696. /**
  57697. * Gets the number of faces
  57698. */
  57699. numberOfFaces: number;
  57700. /**
  57701. * Gets the number of mipmap levels
  57702. */
  57703. numberOfMipmapLevels: number;
  57704. /**
  57705. * Gets the bytes of key value data
  57706. */
  57707. bytesOfKeyValueData: number;
  57708. /**
  57709. * Gets the load type
  57710. */
  57711. loadType: number;
  57712. /**
  57713. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57714. */
  57715. isInvalid: boolean;
  57716. /**
  57717. * Creates a new KhronosTextureContainer
  57718. * @param data contents of the KTX container file
  57719. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57720. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57721. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57722. */
  57723. constructor(
  57724. /** contents of the KTX container file */
  57725. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57726. /**
  57727. * Uploads KTX content to a Babylon Texture.
  57728. * It is assumed that the texture has already been created & is currently bound
  57729. * @hidden
  57730. */
  57731. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57732. private _upload2DCompressedLevels;
  57733. /**
  57734. * Checks if the given data starts with a KTX file identifier.
  57735. * @param data the data to check
  57736. * @returns true if the data is a KTX file or false otherwise
  57737. */
  57738. static IsValid(data: ArrayBufferView): boolean;
  57739. }
  57740. }
  57741. declare module BABYLON {
  57742. /**
  57743. * Helper class to push actions to a pool of workers.
  57744. */
  57745. export class WorkerPool implements IDisposable {
  57746. private _workerInfos;
  57747. private _pendingActions;
  57748. /**
  57749. * Constructor
  57750. * @param workers Array of workers to use for actions
  57751. */
  57752. constructor(workers: Array<Worker>);
  57753. /**
  57754. * Terminates all workers and clears any pending actions.
  57755. */
  57756. dispose(): void;
  57757. /**
  57758. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57759. * pended until a worker has completed its action.
  57760. * @param action The action to perform. Call onComplete when the action is complete.
  57761. */
  57762. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57763. private _execute;
  57764. }
  57765. }
  57766. declare module BABYLON {
  57767. /**
  57768. * Class for loading KTX2 files
  57769. * @hidden
  57770. */
  57771. export class KhronosTextureContainer2 {
  57772. private static _WorkerPoolPromise?;
  57773. private static _Initialized;
  57774. private static _Ktx2Decoder;
  57775. /**
  57776. * URL to use when loading the KTX2 decoder module
  57777. */
  57778. static JSModuleURL: string;
  57779. /**
  57780. * Default number of workers used to handle data decoding
  57781. */
  57782. static DefaultNumWorkers: number;
  57783. private static GetDefaultNumWorkers;
  57784. private _engine;
  57785. private static _CreateWorkerPool;
  57786. /**
  57787. * Constructor
  57788. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57789. */
  57790. constructor(engine: ThinEngine, numWorkers?: number);
  57791. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57792. /**
  57793. * Stop all async operations and release resources.
  57794. */
  57795. dispose(): void;
  57796. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57797. /**
  57798. * Checks if the given data starts with a KTX2 file identifier.
  57799. * @param data the data to check
  57800. * @returns true if the data is a KTX2 file or false otherwise
  57801. */
  57802. static IsValid(data: ArrayBufferView): boolean;
  57803. }
  57804. export function workerFunc(): void;
  57805. }
  57806. declare module BABYLON {
  57807. /**
  57808. * Implementation of the KTX Texture Loader.
  57809. * @hidden
  57810. */
  57811. export class _KTXTextureLoader implements IInternalTextureLoader {
  57812. /**
  57813. * Defines wether the loader supports cascade loading the different faces.
  57814. */
  57815. readonly supportCascades: boolean;
  57816. /**
  57817. * This returns if the loader support the current file information.
  57818. * @param extension defines the file extension of the file being loaded
  57819. * @param mimeType defines the optional mime type of the file being loaded
  57820. * @returns true if the loader can load the specified file
  57821. */
  57822. canLoad(extension: string, mimeType?: string): boolean;
  57823. /**
  57824. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57825. * @param data contains the texture data
  57826. * @param texture defines the BabylonJS internal texture
  57827. * @param createPolynomials will be true if polynomials have been requested
  57828. * @param onLoad defines the callback to trigger once the texture is ready
  57829. * @param onError defines the callback to trigger in case of error
  57830. */
  57831. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57832. /**
  57833. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57834. * @param data contains the texture data
  57835. * @param texture defines the BabylonJS internal texture
  57836. * @param callback defines the method to call once ready to upload
  57837. */
  57838. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57839. }
  57840. }
  57841. declare module BABYLON {
  57842. /** @hidden */
  57843. export var _forceSceneHelpersToBundle: boolean;
  57844. interface Scene {
  57845. /**
  57846. * Creates a default light for the scene.
  57847. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57848. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57849. */
  57850. createDefaultLight(replace?: boolean): void;
  57851. /**
  57852. * Creates a default camera for the scene.
  57853. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57854. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57855. * @param replace has default false, when true replaces the active camera in the scene
  57856. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57857. */
  57858. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57859. /**
  57860. * Creates a default camera and a default light.
  57861. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57862. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57863. * @param replace has the default false, when true replaces the active camera/light in the scene
  57864. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57865. */
  57866. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57867. /**
  57868. * Creates a new sky box
  57869. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57870. * @param environmentTexture defines the texture to use as environment texture
  57871. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57872. * @param scale defines the overall scale of the skybox
  57873. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57874. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57875. * @returns a new mesh holding the sky box
  57876. */
  57877. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57878. /**
  57879. * Creates a new environment
  57880. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57881. * @param options defines the options you can use to configure the environment
  57882. * @returns the new EnvironmentHelper
  57883. */
  57884. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57885. /**
  57886. * Creates a new VREXperienceHelper
  57887. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57888. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57889. * @returns a new VREXperienceHelper
  57890. */
  57891. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57892. /**
  57893. * Creates a new WebXRDefaultExperience
  57894. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57895. * @param options experience options
  57896. * @returns a promise for a new WebXRDefaultExperience
  57897. */
  57898. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57899. }
  57900. }
  57901. declare module BABYLON {
  57902. /**
  57903. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57904. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57905. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57906. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57907. */
  57908. export class VideoDome extends TextureDome<VideoTexture> {
  57909. /**
  57910. * Define the video source as a Monoscopic panoramic 360 video.
  57911. */
  57912. static readonly MODE_MONOSCOPIC: number;
  57913. /**
  57914. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57915. */
  57916. static readonly MODE_TOPBOTTOM: number;
  57917. /**
  57918. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57919. */
  57920. static readonly MODE_SIDEBYSIDE: number;
  57921. /**
  57922. * Get the video texture associated with this video dome
  57923. */
  57924. get videoTexture(): VideoTexture;
  57925. /**
  57926. * Get the video mode of this dome
  57927. */
  57928. get videoMode(): number;
  57929. /**
  57930. * Set the video mode of this dome.
  57931. * @see textureMode
  57932. */
  57933. set videoMode(value: number);
  57934. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  57935. }
  57936. }
  57937. declare module BABYLON {
  57938. /**
  57939. * This class can be used to get instrumentation data from a Babylon engine
  57940. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57941. */
  57942. export class EngineInstrumentation implements IDisposable {
  57943. /**
  57944. * Define the instrumented engine.
  57945. */
  57946. engine: Engine;
  57947. private _captureGPUFrameTime;
  57948. private _gpuFrameTimeToken;
  57949. private _gpuFrameTime;
  57950. private _captureShaderCompilationTime;
  57951. private _shaderCompilationTime;
  57952. private _onBeginFrameObserver;
  57953. private _onEndFrameObserver;
  57954. private _onBeforeShaderCompilationObserver;
  57955. private _onAfterShaderCompilationObserver;
  57956. /**
  57957. * Gets the perf counter used for GPU frame time
  57958. */
  57959. get gpuFrameTimeCounter(): PerfCounter;
  57960. /**
  57961. * Gets the GPU frame time capture status
  57962. */
  57963. get captureGPUFrameTime(): boolean;
  57964. /**
  57965. * Enable or disable the GPU frame time capture
  57966. */
  57967. set captureGPUFrameTime(value: boolean);
  57968. /**
  57969. * Gets the perf counter used for shader compilation time
  57970. */
  57971. get shaderCompilationTimeCounter(): PerfCounter;
  57972. /**
  57973. * Gets the shader compilation time capture status
  57974. */
  57975. get captureShaderCompilationTime(): boolean;
  57976. /**
  57977. * Enable or disable the shader compilation time capture
  57978. */
  57979. set captureShaderCompilationTime(value: boolean);
  57980. /**
  57981. * Instantiates a new engine instrumentation.
  57982. * This class can be used to get instrumentation data from a Babylon engine
  57983. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57984. * @param engine Defines the engine to instrument
  57985. */
  57986. constructor(
  57987. /**
  57988. * Define the instrumented engine.
  57989. */
  57990. engine: Engine);
  57991. /**
  57992. * Dispose and release associated resources.
  57993. */
  57994. dispose(): void;
  57995. }
  57996. }
  57997. declare module BABYLON {
  57998. /**
  57999. * This class can be used to get instrumentation data from a Babylon engine
  58000. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58001. */
  58002. export class SceneInstrumentation implements IDisposable {
  58003. /**
  58004. * Defines the scene to instrument
  58005. */
  58006. scene: Scene;
  58007. private _captureActiveMeshesEvaluationTime;
  58008. private _activeMeshesEvaluationTime;
  58009. private _captureRenderTargetsRenderTime;
  58010. private _renderTargetsRenderTime;
  58011. private _captureFrameTime;
  58012. private _frameTime;
  58013. private _captureRenderTime;
  58014. private _renderTime;
  58015. private _captureInterFrameTime;
  58016. private _interFrameTime;
  58017. private _captureParticlesRenderTime;
  58018. private _particlesRenderTime;
  58019. private _captureSpritesRenderTime;
  58020. private _spritesRenderTime;
  58021. private _capturePhysicsTime;
  58022. private _physicsTime;
  58023. private _captureAnimationsTime;
  58024. private _animationsTime;
  58025. private _captureCameraRenderTime;
  58026. private _cameraRenderTime;
  58027. private _onBeforeActiveMeshesEvaluationObserver;
  58028. private _onAfterActiveMeshesEvaluationObserver;
  58029. private _onBeforeRenderTargetsRenderObserver;
  58030. private _onAfterRenderTargetsRenderObserver;
  58031. private _onAfterRenderObserver;
  58032. private _onBeforeDrawPhaseObserver;
  58033. private _onAfterDrawPhaseObserver;
  58034. private _onBeforeAnimationsObserver;
  58035. private _onBeforeParticlesRenderingObserver;
  58036. private _onAfterParticlesRenderingObserver;
  58037. private _onBeforeSpritesRenderingObserver;
  58038. private _onAfterSpritesRenderingObserver;
  58039. private _onBeforePhysicsObserver;
  58040. private _onAfterPhysicsObserver;
  58041. private _onAfterAnimationsObserver;
  58042. private _onBeforeCameraRenderObserver;
  58043. private _onAfterCameraRenderObserver;
  58044. /**
  58045. * Gets the perf counter used for active meshes evaluation time
  58046. */
  58047. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58048. /**
  58049. * Gets the active meshes evaluation time capture status
  58050. */
  58051. get captureActiveMeshesEvaluationTime(): boolean;
  58052. /**
  58053. * Enable or disable the active meshes evaluation time capture
  58054. */
  58055. set captureActiveMeshesEvaluationTime(value: boolean);
  58056. /**
  58057. * Gets the perf counter used for render targets render time
  58058. */
  58059. get renderTargetsRenderTimeCounter(): PerfCounter;
  58060. /**
  58061. * Gets the render targets render time capture status
  58062. */
  58063. get captureRenderTargetsRenderTime(): boolean;
  58064. /**
  58065. * Enable or disable the render targets render time capture
  58066. */
  58067. set captureRenderTargetsRenderTime(value: boolean);
  58068. /**
  58069. * Gets the perf counter used for particles render time
  58070. */
  58071. get particlesRenderTimeCounter(): PerfCounter;
  58072. /**
  58073. * Gets the particles render time capture status
  58074. */
  58075. get captureParticlesRenderTime(): boolean;
  58076. /**
  58077. * Enable or disable the particles render time capture
  58078. */
  58079. set captureParticlesRenderTime(value: boolean);
  58080. /**
  58081. * Gets the perf counter used for sprites render time
  58082. */
  58083. get spritesRenderTimeCounter(): PerfCounter;
  58084. /**
  58085. * Gets the sprites render time capture status
  58086. */
  58087. get captureSpritesRenderTime(): boolean;
  58088. /**
  58089. * Enable or disable the sprites render time capture
  58090. */
  58091. set captureSpritesRenderTime(value: boolean);
  58092. /**
  58093. * Gets the perf counter used for physics time
  58094. */
  58095. get physicsTimeCounter(): PerfCounter;
  58096. /**
  58097. * Gets the physics time capture status
  58098. */
  58099. get capturePhysicsTime(): boolean;
  58100. /**
  58101. * Enable or disable the physics time capture
  58102. */
  58103. set capturePhysicsTime(value: boolean);
  58104. /**
  58105. * Gets the perf counter used for animations time
  58106. */
  58107. get animationsTimeCounter(): PerfCounter;
  58108. /**
  58109. * Gets the animations time capture status
  58110. */
  58111. get captureAnimationsTime(): boolean;
  58112. /**
  58113. * Enable or disable the animations time capture
  58114. */
  58115. set captureAnimationsTime(value: boolean);
  58116. /**
  58117. * Gets the perf counter used for frame time capture
  58118. */
  58119. get frameTimeCounter(): PerfCounter;
  58120. /**
  58121. * Gets the frame time capture status
  58122. */
  58123. get captureFrameTime(): boolean;
  58124. /**
  58125. * Enable or disable the frame time capture
  58126. */
  58127. set captureFrameTime(value: boolean);
  58128. /**
  58129. * Gets the perf counter used for inter-frames time capture
  58130. */
  58131. get interFrameTimeCounter(): PerfCounter;
  58132. /**
  58133. * Gets the inter-frames time capture status
  58134. */
  58135. get captureInterFrameTime(): boolean;
  58136. /**
  58137. * Enable or disable the inter-frames time capture
  58138. */
  58139. set captureInterFrameTime(value: boolean);
  58140. /**
  58141. * Gets the perf counter used for render time capture
  58142. */
  58143. get renderTimeCounter(): PerfCounter;
  58144. /**
  58145. * Gets the render time capture status
  58146. */
  58147. get captureRenderTime(): boolean;
  58148. /**
  58149. * Enable or disable the render time capture
  58150. */
  58151. set captureRenderTime(value: boolean);
  58152. /**
  58153. * Gets the perf counter used for camera render time capture
  58154. */
  58155. get cameraRenderTimeCounter(): PerfCounter;
  58156. /**
  58157. * Gets the camera render time capture status
  58158. */
  58159. get captureCameraRenderTime(): boolean;
  58160. /**
  58161. * Enable or disable the camera render time capture
  58162. */
  58163. set captureCameraRenderTime(value: boolean);
  58164. /**
  58165. * Gets the perf counter used for draw calls
  58166. */
  58167. get drawCallsCounter(): PerfCounter;
  58168. /**
  58169. * Instantiates a new scene instrumentation.
  58170. * This class can be used to get instrumentation data from a Babylon engine
  58171. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58172. * @param scene Defines the scene to instrument
  58173. */
  58174. constructor(
  58175. /**
  58176. * Defines the scene to instrument
  58177. */
  58178. scene: Scene);
  58179. /**
  58180. * Dispose and release associated resources.
  58181. */
  58182. dispose(): void;
  58183. }
  58184. }
  58185. declare module BABYLON {
  58186. /** @hidden */
  58187. export var glowMapGenerationPixelShader: {
  58188. name: string;
  58189. shader: string;
  58190. };
  58191. }
  58192. declare module BABYLON {
  58193. /** @hidden */
  58194. export var glowMapGenerationVertexShader: {
  58195. name: string;
  58196. shader: string;
  58197. };
  58198. }
  58199. declare module BABYLON {
  58200. /**
  58201. * Effect layer options. This helps customizing the behaviour
  58202. * of the effect layer.
  58203. */
  58204. export interface IEffectLayerOptions {
  58205. /**
  58206. * Multiplication factor apply to the canvas size to compute the render target size
  58207. * used to generated the objects (the smaller the faster).
  58208. */
  58209. mainTextureRatio: number;
  58210. /**
  58211. * Enforces a fixed size texture to ensure effect stability across devices.
  58212. */
  58213. mainTextureFixedSize?: number;
  58214. /**
  58215. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58216. */
  58217. alphaBlendingMode: number;
  58218. /**
  58219. * The camera attached to the layer.
  58220. */
  58221. camera: Nullable<Camera>;
  58222. /**
  58223. * The rendering group to draw the layer in.
  58224. */
  58225. renderingGroupId: number;
  58226. }
  58227. /**
  58228. * The effect layer Helps adding post process effect blended with the main pass.
  58229. *
  58230. * This can be for instance use to generate glow or higlight effects on the scene.
  58231. *
  58232. * The effect layer class can not be used directly and is intented to inherited from to be
  58233. * customized per effects.
  58234. */
  58235. export abstract class EffectLayer {
  58236. private _vertexBuffers;
  58237. private _indexBuffer;
  58238. private _cachedDefines;
  58239. private _effectLayerMapGenerationEffect;
  58240. private _effectLayerOptions;
  58241. private _mergeEffect;
  58242. protected _scene: Scene;
  58243. protected _engine: Engine;
  58244. protected _maxSize: number;
  58245. protected _mainTextureDesiredSize: ISize;
  58246. protected _mainTexture: RenderTargetTexture;
  58247. protected _shouldRender: boolean;
  58248. protected _postProcesses: PostProcess[];
  58249. protected _textures: BaseTexture[];
  58250. protected _emissiveTextureAndColor: {
  58251. texture: Nullable<BaseTexture>;
  58252. color: Color4;
  58253. };
  58254. /**
  58255. * The name of the layer
  58256. */
  58257. name: string;
  58258. /**
  58259. * The clear color of the texture used to generate the glow map.
  58260. */
  58261. neutralColor: Color4;
  58262. /**
  58263. * Specifies whether the highlight layer is enabled or not.
  58264. */
  58265. isEnabled: boolean;
  58266. /**
  58267. * Gets the camera attached to the layer.
  58268. */
  58269. get camera(): Nullable<Camera>;
  58270. /**
  58271. * Gets the rendering group id the layer should render in.
  58272. */
  58273. get renderingGroupId(): number;
  58274. set renderingGroupId(renderingGroupId: number);
  58275. /**
  58276. * An event triggered when the effect layer has been disposed.
  58277. */
  58278. onDisposeObservable: Observable<EffectLayer>;
  58279. /**
  58280. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58281. */
  58282. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58283. /**
  58284. * An event triggered when the generated texture is being merged in the scene.
  58285. */
  58286. onBeforeComposeObservable: Observable<EffectLayer>;
  58287. /**
  58288. * An event triggered when the mesh is rendered into the effect render target.
  58289. */
  58290. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58291. /**
  58292. * An event triggered after the mesh has been rendered into the effect render target.
  58293. */
  58294. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58295. /**
  58296. * An event triggered when the generated texture has been merged in the scene.
  58297. */
  58298. onAfterComposeObservable: Observable<EffectLayer>;
  58299. /**
  58300. * An event triggered when the efffect layer changes its size.
  58301. */
  58302. onSizeChangedObservable: Observable<EffectLayer>;
  58303. /** @hidden */
  58304. static _SceneComponentInitialization: (scene: Scene) => void;
  58305. /**
  58306. * Instantiates a new effect Layer and references it in the scene.
  58307. * @param name The name of the layer
  58308. * @param scene The scene to use the layer in
  58309. */
  58310. constructor(
  58311. /** The Friendly of the effect in the scene */
  58312. name: string, scene: Scene);
  58313. /**
  58314. * Get the effect name of the layer.
  58315. * @return The effect name
  58316. */
  58317. abstract getEffectName(): string;
  58318. /**
  58319. * Checks for the readiness of the element composing the layer.
  58320. * @param subMesh the mesh to check for
  58321. * @param useInstances specify whether or not to use instances to render the mesh
  58322. * @return true if ready otherwise, false
  58323. */
  58324. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58325. /**
  58326. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58327. * @returns true if the effect requires stencil during the main canvas render pass.
  58328. */
  58329. abstract needStencil(): boolean;
  58330. /**
  58331. * Create the merge effect. This is the shader use to blit the information back
  58332. * to the main canvas at the end of the scene rendering.
  58333. * @returns The effect containing the shader used to merge the effect on the main canvas
  58334. */
  58335. protected abstract _createMergeEffect(): Effect;
  58336. /**
  58337. * Creates the render target textures and post processes used in the effect layer.
  58338. */
  58339. protected abstract _createTextureAndPostProcesses(): void;
  58340. /**
  58341. * Implementation specific of rendering the generating effect on the main canvas.
  58342. * @param effect The effect used to render through
  58343. */
  58344. protected abstract _internalRender(effect: Effect): void;
  58345. /**
  58346. * Sets the required values for both the emissive texture and and the main color.
  58347. */
  58348. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58349. /**
  58350. * Free any resources and references associated to a mesh.
  58351. * Internal use
  58352. * @param mesh The mesh to free.
  58353. */
  58354. abstract _disposeMesh(mesh: Mesh): void;
  58355. /**
  58356. * Serializes this layer (Glow or Highlight for example)
  58357. * @returns a serialized layer object
  58358. */
  58359. abstract serialize?(): any;
  58360. /**
  58361. * Initializes the effect layer with the required options.
  58362. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58363. */
  58364. protected _init(options: Partial<IEffectLayerOptions>): void;
  58365. /**
  58366. * Generates the index buffer of the full screen quad blending to the main canvas.
  58367. */
  58368. private _generateIndexBuffer;
  58369. /**
  58370. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58371. */
  58372. private _generateVertexBuffer;
  58373. /**
  58374. * Sets the main texture desired size which is the closest power of two
  58375. * of the engine canvas size.
  58376. */
  58377. private _setMainTextureSize;
  58378. /**
  58379. * Creates the main texture for the effect layer.
  58380. */
  58381. protected _createMainTexture(): void;
  58382. /**
  58383. * Adds specific effects defines.
  58384. * @param defines The defines to add specifics to.
  58385. */
  58386. protected _addCustomEffectDefines(defines: string[]): void;
  58387. /**
  58388. * Checks for the readiness of the element composing the layer.
  58389. * @param subMesh the mesh to check for
  58390. * @param useInstances specify whether or not to use instances to render the mesh
  58391. * @param emissiveTexture the associated emissive texture used to generate the glow
  58392. * @return true if ready otherwise, false
  58393. */
  58394. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58395. /**
  58396. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58397. */
  58398. render(): void;
  58399. /**
  58400. * Determine if a given mesh will be used in the current effect.
  58401. * @param mesh mesh to test
  58402. * @returns true if the mesh will be used
  58403. */
  58404. hasMesh(mesh: AbstractMesh): boolean;
  58405. /**
  58406. * Returns true if the layer contains information to display, otherwise false.
  58407. * @returns true if the glow layer should be rendered
  58408. */
  58409. shouldRender(): boolean;
  58410. /**
  58411. * Returns true if the mesh should render, otherwise false.
  58412. * @param mesh The mesh to render
  58413. * @returns true if it should render otherwise false
  58414. */
  58415. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58416. /**
  58417. * Returns true if the mesh can be rendered, otherwise false.
  58418. * @param mesh The mesh to render
  58419. * @param material The material used on the mesh
  58420. * @returns true if it can be rendered otherwise false
  58421. */
  58422. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58423. /**
  58424. * Returns true if the mesh should render, otherwise false.
  58425. * @param mesh The mesh to render
  58426. * @returns true if it should render otherwise false
  58427. */
  58428. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58429. /**
  58430. * Renders the submesh passed in parameter to the generation map.
  58431. */
  58432. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58433. /**
  58434. * Defines whether the current material of the mesh should be use to render the effect.
  58435. * @param mesh defines the current mesh to render
  58436. */
  58437. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58438. /**
  58439. * Rebuild the required buffers.
  58440. * @hidden Internal use only.
  58441. */
  58442. _rebuild(): void;
  58443. /**
  58444. * Dispose only the render target textures and post process.
  58445. */
  58446. private _disposeTextureAndPostProcesses;
  58447. /**
  58448. * Dispose the highlight layer and free resources.
  58449. */
  58450. dispose(): void;
  58451. /**
  58452. * Gets the class name of the effect layer
  58453. * @returns the string with the class name of the effect layer
  58454. */
  58455. getClassName(): string;
  58456. /**
  58457. * Creates an effect layer from parsed effect layer data
  58458. * @param parsedEffectLayer defines effect layer data
  58459. * @param scene defines the current scene
  58460. * @param rootUrl defines the root URL containing the effect layer information
  58461. * @returns a parsed effect Layer
  58462. */
  58463. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. interface AbstractScene {
  58468. /**
  58469. * The list of effect layers (highlights/glow) added to the scene
  58470. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58471. * @see https://doc.babylonjs.com/how_to/glow_layer
  58472. */
  58473. effectLayers: Array<EffectLayer>;
  58474. /**
  58475. * Removes the given effect layer from this scene.
  58476. * @param toRemove defines the effect layer to remove
  58477. * @returns the index of the removed effect layer
  58478. */
  58479. removeEffectLayer(toRemove: EffectLayer): number;
  58480. /**
  58481. * Adds the given effect layer to this scene
  58482. * @param newEffectLayer defines the effect layer to add
  58483. */
  58484. addEffectLayer(newEffectLayer: EffectLayer): void;
  58485. }
  58486. /**
  58487. * Defines the layer scene component responsible to manage any effect layers
  58488. * in a given scene.
  58489. */
  58490. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58491. /**
  58492. * The component name helpfull to identify the component in the list of scene components.
  58493. */
  58494. readonly name: string;
  58495. /**
  58496. * The scene the component belongs to.
  58497. */
  58498. scene: Scene;
  58499. private _engine;
  58500. private _renderEffects;
  58501. private _needStencil;
  58502. private _previousStencilState;
  58503. /**
  58504. * Creates a new instance of the component for the given scene
  58505. * @param scene Defines the scene to register the component in
  58506. */
  58507. constructor(scene: Scene);
  58508. /**
  58509. * Registers the component in a given scene
  58510. */
  58511. register(): void;
  58512. /**
  58513. * Rebuilds the elements related to this component in case of
  58514. * context lost for instance.
  58515. */
  58516. rebuild(): void;
  58517. /**
  58518. * Serializes the component data to the specified json object
  58519. * @param serializationObject The object to serialize to
  58520. */
  58521. serialize(serializationObject: any): void;
  58522. /**
  58523. * Adds all the elements from the container to the scene
  58524. * @param container the container holding the elements
  58525. */
  58526. addFromContainer(container: AbstractScene): void;
  58527. /**
  58528. * Removes all the elements in the container from the scene
  58529. * @param container contains the elements to remove
  58530. * @param dispose if the removed element should be disposed (default: false)
  58531. */
  58532. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58533. /**
  58534. * Disposes the component and the associated ressources.
  58535. */
  58536. dispose(): void;
  58537. private _isReadyForMesh;
  58538. private _renderMainTexture;
  58539. private _setStencil;
  58540. private _setStencilBack;
  58541. private _draw;
  58542. private _drawCamera;
  58543. private _drawRenderingGroup;
  58544. }
  58545. }
  58546. declare module BABYLON {
  58547. /** @hidden */
  58548. export var glowMapMergePixelShader: {
  58549. name: string;
  58550. shader: string;
  58551. };
  58552. }
  58553. declare module BABYLON {
  58554. /** @hidden */
  58555. export var glowMapMergeVertexShader: {
  58556. name: string;
  58557. shader: string;
  58558. };
  58559. }
  58560. declare module BABYLON {
  58561. interface AbstractScene {
  58562. /**
  58563. * Return a the first highlight layer of the scene with a given name.
  58564. * @param name The name of the highlight layer to look for.
  58565. * @return The highlight layer if found otherwise null.
  58566. */
  58567. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58568. }
  58569. /**
  58570. * Glow layer options. This helps customizing the behaviour
  58571. * of the glow layer.
  58572. */
  58573. export interface IGlowLayerOptions {
  58574. /**
  58575. * Multiplication factor apply to the canvas size to compute the render target size
  58576. * used to generated the glowing objects (the smaller the faster).
  58577. */
  58578. mainTextureRatio: number;
  58579. /**
  58580. * Enforces a fixed size texture to ensure resize independant blur.
  58581. */
  58582. mainTextureFixedSize?: number;
  58583. /**
  58584. * How big is the kernel of the blur texture.
  58585. */
  58586. blurKernelSize: number;
  58587. /**
  58588. * The camera attached to the layer.
  58589. */
  58590. camera: Nullable<Camera>;
  58591. /**
  58592. * Enable MSAA by chosing the number of samples.
  58593. */
  58594. mainTextureSamples?: number;
  58595. /**
  58596. * The rendering group to draw the layer in.
  58597. */
  58598. renderingGroupId: number;
  58599. }
  58600. /**
  58601. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58602. *
  58603. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58604. *
  58605. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58606. */
  58607. export class GlowLayer extends EffectLayer {
  58608. /**
  58609. * Effect Name of the layer.
  58610. */
  58611. static readonly EffectName: string;
  58612. /**
  58613. * The default blur kernel size used for the glow.
  58614. */
  58615. static DefaultBlurKernelSize: number;
  58616. /**
  58617. * The default texture size ratio used for the glow.
  58618. */
  58619. static DefaultTextureRatio: number;
  58620. /**
  58621. * Sets the kernel size of the blur.
  58622. */
  58623. set blurKernelSize(value: number);
  58624. /**
  58625. * Gets the kernel size of the blur.
  58626. */
  58627. get blurKernelSize(): number;
  58628. /**
  58629. * Sets the glow intensity.
  58630. */
  58631. set intensity(value: number);
  58632. /**
  58633. * Gets the glow intensity.
  58634. */
  58635. get intensity(): number;
  58636. private _options;
  58637. private _intensity;
  58638. private _horizontalBlurPostprocess1;
  58639. private _verticalBlurPostprocess1;
  58640. private _horizontalBlurPostprocess2;
  58641. private _verticalBlurPostprocess2;
  58642. private _blurTexture1;
  58643. private _blurTexture2;
  58644. private _postProcesses1;
  58645. private _postProcesses2;
  58646. private _includedOnlyMeshes;
  58647. private _excludedMeshes;
  58648. private _meshesUsingTheirOwnMaterials;
  58649. /**
  58650. * Callback used to let the user override the color selection on a per mesh basis
  58651. */
  58652. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58653. /**
  58654. * Callback used to let the user override the texture selection on a per mesh basis
  58655. */
  58656. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58657. /**
  58658. * Instantiates a new glow Layer and references it to the scene.
  58659. * @param name The name of the layer
  58660. * @param scene The scene to use the layer in
  58661. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58662. */
  58663. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58664. /**
  58665. * Get the effect name of the layer.
  58666. * @return The effect name
  58667. */
  58668. getEffectName(): string;
  58669. /**
  58670. * Create the merge effect. This is the shader use to blit the information back
  58671. * to the main canvas at the end of the scene rendering.
  58672. */
  58673. protected _createMergeEffect(): Effect;
  58674. /**
  58675. * Creates the render target textures and post processes used in the glow layer.
  58676. */
  58677. protected _createTextureAndPostProcesses(): void;
  58678. /**
  58679. * Checks for the readiness of the element composing the layer.
  58680. * @param subMesh the mesh to check for
  58681. * @param useInstances specify wether or not to use instances to render the mesh
  58682. * @param emissiveTexture the associated emissive texture used to generate the glow
  58683. * @return true if ready otherwise, false
  58684. */
  58685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58686. /**
  58687. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58688. */
  58689. needStencil(): boolean;
  58690. /**
  58691. * Returns true if the mesh can be rendered, otherwise false.
  58692. * @param mesh The mesh to render
  58693. * @param material The material used on the mesh
  58694. * @returns true if it can be rendered otherwise false
  58695. */
  58696. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58697. /**
  58698. * Implementation specific of rendering the generating effect on the main canvas.
  58699. * @param effect The effect used to render through
  58700. */
  58701. protected _internalRender(effect: Effect): void;
  58702. /**
  58703. * Sets the required values for both the emissive texture and and the main color.
  58704. */
  58705. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58706. /**
  58707. * Returns true if the mesh should render, otherwise false.
  58708. * @param mesh The mesh to render
  58709. * @returns true if it should render otherwise false
  58710. */
  58711. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58712. /**
  58713. * Adds specific effects defines.
  58714. * @param defines The defines to add specifics to.
  58715. */
  58716. protected _addCustomEffectDefines(defines: string[]): void;
  58717. /**
  58718. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58719. * @param mesh The mesh to exclude from the glow layer
  58720. */
  58721. addExcludedMesh(mesh: Mesh): void;
  58722. /**
  58723. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58724. * @param mesh The mesh to remove
  58725. */
  58726. removeExcludedMesh(mesh: Mesh): void;
  58727. /**
  58728. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58729. * @param mesh The mesh to include in the glow layer
  58730. */
  58731. addIncludedOnlyMesh(mesh: Mesh): void;
  58732. /**
  58733. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58734. * @param mesh The mesh to remove
  58735. */
  58736. removeIncludedOnlyMesh(mesh: Mesh): void;
  58737. /**
  58738. * Determine if a given mesh will be used in the glow layer
  58739. * @param mesh The mesh to test
  58740. * @returns true if the mesh will be highlighted by the current glow layer
  58741. */
  58742. hasMesh(mesh: AbstractMesh): boolean;
  58743. /**
  58744. * Defines whether the current material of the mesh should be use to render the effect.
  58745. * @param mesh defines the current mesh to render
  58746. */
  58747. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58748. /**
  58749. * Add a mesh to be rendered through its own material and not with emissive only.
  58750. * @param mesh The mesh for which we need to use its material
  58751. */
  58752. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58753. /**
  58754. * Remove a mesh from being rendered through its own material and not with emissive only.
  58755. * @param mesh The mesh for which we need to not use its material
  58756. */
  58757. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58758. /**
  58759. * Free any resources and references associated to a mesh.
  58760. * Internal use
  58761. * @param mesh The mesh to free.
  58762. * @hidden
  58763. */
  58764. _disposeMesh(mesh: Mesh): void;
  58765. /**
  58766. * Gets the class name of the effect layer
  58767. * @returns the string with the class name of the effect layer
  58768. */
  58769. getClassName(): string;
  58770. /**
  58771. * Serializes this glow layer
  58772. * @returns a serialized glow layer object
  58773. */
  58774. serialize(): any;
  58775. /**
  58776. * Creates a Glow Layer from parsed glow layer data
  58777. * @param parsedGlowLayer defines glow layer data
  58778. * @param scene defines the current scene
  58779. * @param rootUrl defines the root URL containing the glow layer information
  58780. * @returns a parsed Glow Layer
  58781. */
  58782. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58783. }
  58784. }
  58785. declare module BABYLON {
  58786. /** @hidden */
  58787. export var glowBlurPostProcessPixelShader: {
  58788. name: string;
  58789. shader: string;
  58790. };
  58791. }
  58792. declare module BABYLON {
  58793. interface AbstractScene {
  58794. /**
  58795. * Return a the first highlight layer of the scene with a given name.
  58796. * @param name The name of the highlight layer to look for.
  58797. * @return The highlight layer if found otherwise null.
  58798. */
  58799. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58800. }
  58801. /**
  58802. * Highlight layer options. This helps customizing the behaviour
  58803. * of the highlight layer.
  58804. */
  58805. export interface IHighlightLayerOptions {
  58806. /**
  58807. * Multiplication factor apply to the canvas size to compute the render target size
  58808. * used to generated the glowing objects (the smaller the faster).
  58809. */
  58810. mainTextureRatio: number;
  58811. /**
  58812. * Enforces a fixed size texture to ensure resize independant blur.
  58813. */
  58814. mainTextureFixedSize?: number;
  58815. /**
  58816. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58817. * of the picture to blur (the smaller the faster).
  58818. */
  58819. blurTextureSizeRatio: number;
  58820. /**
  58821. * How big in texel of the blur texture is the vertical blur.
  58822. */
  58823. blurVerticalSize: number;
  58824. /**
  58825. * How big in texel of the blur texture is the horizontal blur.
  58826. */
  58827. blurHorizontalSize: number;
  58828. /**
  58829. * Alpha blending mode used to apply the blur. Default is combine.
  58830. */
  58831. alphaBlendingMode: number;
  58832. /**
  58833. * The camera attached to the layer.
  58834. */
  58835. camera: Nullable<Camera>;
  58836. /**
  58837. * Should we display highlight as a solid stroke?
  58838. */
  58839. isStroke?: boolean;
  58840. /**
  58841. * The rendering group to draw the layer in.
  58842. */
  58843. renderingGroupId: number;
  58844. }
  58845. /**
  58846. * The highlight layer Helps adding a glow effect around a mesh.
  58847. *
  58848. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58849. * glowy meshes to your scene.
  58850. *
  58851. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58852. */
  58853. export class HighlightLayer extends EffectLayer {
  58854. name: string;
  58855. /**
  58856. * Effect Name of the highlight layer.
  58857. */
  58858. static readonly EffectName: string;
  58859. /**
  58860. * The neutral color used during the preparation of the glow effect.
  58861. * This is black by default as the blend operation is a blend operation.
  58862. */
  58863. static NeutralColor: Color4;
  58864. /**
  58865. * Stencil value used for glowing meshes.
  58866. */
  58867. static GlowingMeshStencilReference: number;
  58868. /**
  58869. * Stencil value used for the other meshes in the scene.
  58870. */
  58871. static NormalMeshStencilReference: number;
  58872. /**
  58873. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58874. */
  58875. innerGlow: boolean;
  58876. /**
  58877. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58878. */
  58879. outerGlow: boolean;
  58880. /**
  58881. * Specifies the horizontal size of the blur.
  58882. */
  58883. set blurHorizontalSize(value: number);
  58884. /**
  58885. * Specifies the vertical size of the blur.
  58886. */
  58887. set blurVerticalSize(value: number);
  58888. /**
  58889. * Gets the horizontal size of the blur.
  58890. */
  58891. get blurHorizontalSize(): number;
  58892. /**
  58893. * Gets the vertical size of the blur.
  58894. */
  58895. get blurVerticalSize(): number;
  58896. /**
  58897. * An event triggered when the highlight layer is being blurred.
  58898. */
  58899. onBeforeBlurObservable: Observable<HighlightLayer>;
  58900. /**
  58901. * An event triggered when the highlight layer has been blurred.
  58902. */
  58903. onAfterBlurObservable: Observable<HighlightLayer>;
  58904. private _instanceGlowingMeshStencilReference;
  58905. private _options;
  58906. private _downSamplePostprocess;
  58907. private _horizontalBlurPostprocess;
  58908. private _verticalBlurPostprocess;
  58909. private _blurTexture;
  58910. private _meshes;
  58911. private _excludedMeshes;
  58912. /**
  58913. * Instantiates a new highlight Layer and references it to the scene..
  58914. * @param name The name of the layer
  58915. * @param scene The scene to use the layer in
  58916. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58917. */
  58918. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58919. /**
  58920. * Get the effect name of the layer.
  58921. * @return The effect name
  58922. */
  58923. getEffectName(): string;
  58924. /**
  58925. * Create the merge effect. This is the shader use to blit the information back
  58926. * to the main canvas at the end of the scene rendering.
  58927. */
  58928. protected _createMergeEffect(): Effect;
  58929. /**
  58930. * Creates the render target textures and post processes used in the highlight layer.
  58931. */
  58932. protected _createTextureAndPostProcesses(): void;
  58933. /**
  58934. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58935. */
  58936. needStencil(): boolean;
  58937. /**
  58938. * Checks for the readiness of the element composing the layer.
  58939. * @param subMesh the mesh to check for
  58940. * @param useInstances specify wether or not to use instances to render the mesh
  58941. * @param emissiveTexture the associated emissive texture used to generate the glow
  58942. * @return true if ready otherwise, false
  58943. */
  58944. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58945. /**
  58946. * Implementation specific of rendering the generating effect on the main canvas.
  58947. * @param effect The effect used to render through
  58948. */
  58949. protected _internalRender(effect: Effect): void;
  58950. /**
  58951. * Returns true if the layer contains information to display, otherwise false.
  58952. */
  58953. shouldRender(): boolean;
  58954. /**
  58955. * Returns true if the mesh should render, otherwise false.
  58956. * @param mesh The mesh to render
  58957. * @returns true if it should render otherwise false
  58958. */
  58959. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58960. /**
  58961. * Returns true if the mesh can be rendered, otherwise false.
  58962. * @param mesh The mesh to render
  58963. * @param material The material used on the mesh
  58964. * @returns true if it can be rendered otherwise false
  58965. */
  58966. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58967. /**
  58968. * Adds specific effects defines.
  58969. * @param defines The defines to add specifics to.
  58970. */
  58971. protected _addCustomEffectDefines(defines: string[]): void;
  58972. /**
  58973. * Sets the required values for both the emissive texture and and the main color.
  58974. */
  58975. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58976. /**
  58977. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58978. * @param mesh The mesh to exclude from the highlight layer
  58979. */
  58980. addExcludedMesh(mesh: Mesh): void;
  58981. /**
  58982. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58983. * @param mesh The mesh to highlight
  58984. */
  58985. removeExcludedMesh(mesh: Mesh): void;
  58986. /**
  58987. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58988. * @param mesh mesh to test
  58989. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58990. */
  58991. hasMesh(mesh: AbstractMesh): boolean;
  58992. /**
  58993. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58994. * @param mesh The mesh to highlight
  58995. * @param color The color of the highlight
  58996. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58997. */
  58998. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58999. /**
  59000. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59001. * @param mesh The mesh to highlight
  59002. */
  59003. removeMesh(mesh: Mesh): void;
  59004. /**
  59005. * Remove all the meshes currently referenced in the highlight layer
  59006. */
  59007. removeAllMeshes(): void;
  59008. /**
  59009. * Force the stencil to the normal expected value for none glowing parts
  59010. */
  59011. private _defaultStencilReference;
  59012. /**
  59013. * Free any resources and references associated to a mesh.
  59014. * Internal use
  59015. * @param mesh The mesh to free.
  59016. * @hidden
  59017. */
  59018. _disposeMesh(mesh: Mesh): void;
  59019. /**
  59020. * Dispose the highlight layer and free resources.
  59021. */
  59022. dispose(): void;
  59023. /**
  59024. * Gets the class name of the effect layer
  59025. * @returns the string with the class name of the effect layer
  59026. */
  59027. getClassName(): string;
  59028. /**
  59029. * Serializes this Highlight layer
  59030. * @returns a serialized Highlight layer object
  59031. */
  59032. serialize(): any;
  59033. /**
  59034. * Creates a Highlight layer from parsed Highlight layer data
  59035. * @param parsedHightlightLayer defines the Highlight layer data
  59036. * @param scene defines the current scene
  59037. * @param rootUrl defines the root URL containing the Highlight layer information
  59038. * @returns a parsed Highlight layer
  59039. */
  59040. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59041. }
  59042. }
  59043. declare module BABYLON {
  59044. interface AbstractScene {
  59045. /**
  59046. * The list of layers (background and foreground) of the scene
  59047. */
  59048. layers: Array<Layer>;
  59049. }
  59050. /**
  59051. * Defines the layer scene component responsible to manage any layers
  59052. * in a given scene.
  59053. */
  59054. export class LayerSceneComponent implements ISceneComponent {
  59055. /**
  59056. * The component name helpfull to identify the component in the list of scene components.
  59057. */
  59058. readonly name: string;
  59059. /**
  59060. * The scene the component belongs to.
  59061. */
  59062. scene: Scene;
  59063. private _engine;
  59064. /**
  59065. * Creates a new instance of the component for the given scene
  59066. * @param scene Defines the scene to register the component in
  59067. */
  59068. constructor(scene: Scene);
  59069. /**
  59070. * Registers the component in a given scene
  59071. */
  59072. register(): void;
  59073. /**
  59074. * Rebuilds the elements related to this component in case of
  59075. * context lost for instance.
  59076. */
  59077. rebuild(): void;
  59078. /**
  59079. * Disposes the component and the associated ressources.
  59080. */
  59081. dispose(): void;
  59082. private _draw;
  59083. private _drawCameraPredicate;
  59084. private _drawCameraBackground;
  59085. private _drawCameraForeground;
  59086. private _drawRenderTargetPredicate;
  59087. private _drawRenderTargetBackground;
  59088. private _drawRenderTargetForeground;
  59089. /**
  59090. * Adds all the elements from the container to the scene
  59091. * @param container the container holding the elements
  59092. */
  59093. addFromContainer(container: AbstractScene): void;
  59094. /**
  59095. * Removes all the elements in the container from the scene
  59096. * @param container contains the elements to remove
  59097. * @param dispose if the removed element should be disposed (default: false)
  59098. */
  59099. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59100. }
  59101. }
  59102. declare module BABYLON {
  59103. /** @hidden */
  59104. export var layerPixelShader: {
  59105. name: string;
  59106. shader: string;
  59107. };
  59108. }
  59109. declare module BABYLON {
  59110. /** @hidden */
  59111. export var layerVertexShader: {
  59112. name: string;
  59113. shader: string;
  59114. };
  59115. }
  59116. declare module BABYLON {
  59117. /**
  59118. * This represents a full screen 2d layer.
  59119. * This can be useful to display a picture in the background of your scene for instance.
  59120. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59121. */
  59122. export class Layer {
  59123. /**
  59124. * Define the name of the layer.
  59125. */
  59126. name: string;
  59127. /**
  59128. * Define the texture the layer should display.
  59129. */
  59130. texture: Nullable<Texture>;
  59131. /**
  59132. * Is the layer in background or foreground.
  59133. */
  59134. isBackground: boolean;
  59135. /**
  59136. * Define the color of the layer (instead of texture).
  59137. */
  59138. color: Color4;
  59139. /**
  59140. * Define the scale of the layer in order to zoom in out of the texture.
  59141. */
  59142. scale: Vector2;
  59143. /**
  59144. * Define an offset for the layer in order to shift the texture.
  59145. */
  59146. offset: Vector2;
  59147. /**
  59148. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59149. */
  59150. alphaBlendingMode: number;
  59151. /**
  59152. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59153. * Alpha test will not mix with the background color in case of transparency.
  59154. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59155. */
  59156. alphaTest: boolean;
  59157. /**
  59158. * Define a mask to restrict the layer to only some of the scene cameras.
  59159. */
  59160. layerMask: number;
  59161. /**
  59162. * Define the list of render target the layer is visible into.
  59163. */
  59164. renderTargetTextures: RenderTargetTexture[];
  59165. /**
  59166. * Define if the layer is only used in renderTarget or if it also
  59167. * renders in the main frame buffer of the canvas.
  59168. */
  59169. renderOnlyInRenderTargetTextures: boolean;
  59170. private _scene;
  59171. private _vertexBuffers;
  59172. private _indexBuffer;
  59173. private _effect;
  59174. private _previousDefines;
  59175. /**
  59176. * An event triggered when the layer is disposed.
  59177. */
  59178. onDisposeObservable: Observable<Layer>;
  59179. private _onDisposeObserver;
  59180. /**
  59181. * Back compatibility with callback before the onDisposeObservable existed.
  59182. * The set callback will be triggered when the layer has been disposed.
  59183. */
  59184. set onDispose(callback: () => void);
  59185. /**
  59186. * An event triggered before rendering the scene
  59187. */
  59188. onBeforeRenderObservable: Observable<Layer>;
  59189. private _onBeforeRenderObserver;
  59190. /**
  59191. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59192. * The set callback will be triggered just before rendering the layer.
  59193. */
  59194. set onBeforeRender(callback: () => void);
  59195. /**
  59196. * An event triggered after rendering the scene
  59197. */
  59198. onAfterRenderObservable: Observable<Layer>;
  59199. private _onAfterRenderObserver;
  59200. /**
  59201. * Back compatibility with callback before the onAfterRenderObservable existed.
  59202. * The set callback will be triggered just after rendering the layer.
  59203. */
  59204. set onAfterRender(callback: () => void);
  59205. /**
  59206. * Instantiates a new layer.
  59207. * This represents a full screen 2d layer.
  59208. * This can be useful to display a picture in the background of your scene for instance.
  59209. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59210. * @param name Define the name of the layer in the scene
  59211. * @param imgUrl Define the url of the texture to display in the layer
  59212. * @param scene Define the scene the layer belongs to
  59213. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59214. * @param color Defines a color for the layer
  59215. */
  59216. constructor(
  59217. /**
  59218. * Define the name of the layer.
  59219. */
  59220. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59221. private _createIndexBuffer;
  59222. /** @hidden */
  59223. _rebuild(): void;
  59224. /**
  59225. * Renders the layer in the scene.
  59226. */
  59227. render(): void;
  59228. /**
  59229. * Disposes and releases the associated ressources.
  59230. */
  59231. dispose(): void;
  59232. }
  59233. }
  59234. declare module BABYLON {
  59235. /** @hidden */
  59236. export var lensFlarePixelShader: {
  59237. name: string;
  59238. shader: string;
  59239. };
  59240. }
  59241. declare module BABYLON {
  59242. /** @hidden */
  59243. export var lensFlareVertexShader: {
  59244. name: string;
  59245. shader: string;
  59246. };
  59247. }
  59248. declare module BABYLON {
  59249. /**
  59250. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59251. * It is usually composed of several `lensFlare`.
  59252. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59253. */
  59254. export class LensFlareSystem {
  59255. /**
  59256. * Define the name of the lens flare system
  59257. */
  59258. name: string;
  59259. /**
  59260. * List of lens flares used in this system.
  59261. */
  59262. lensFlares: LensFlare[];
  59263. /**
  59264. * Define a limit from the border the lens flare can be visible.
  59265. */
  59266. borderLimit: number;
  59267. /**
  59268. * Define a viewport border we do not want to see the lens flare in.
  59269. */
  59270. viewportBorder: number;
  59271. /**
  59272. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59273. */
  59274. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59275. /**
  59276. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59277. */
  59278. layerMask: number;
  59279. /**
  59280. * Define the id of the lens flare system in the scene.
  59281. * (equal to name by default)
  59282. */
  59283. id: string;
  59284. private _scene;
  59285. private _emitter;
  59286. private _vertexBuffers;
  59287. private _indexBuffer;
  59288. private _effect;
  59289. private _positionX;
  59290. private _positionY;
  59291. private _isEnabled;
  59292. /** @hidden */
  59293. static _SceneComponentInitialization: (scene: Scene) => void;
  59294. /**
  59295. * Instantiates a lens flare system.
  59296. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59297. * It is usually composed of several `lensFlare`.
  59298. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59299. * @param name Define the name of the lens flare system in the scene
  59300. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59301. * @param scene Define the scene the lens flare system belongs to
  59302. */
  59303. constructor(
  59304. /**
  59305. * Define the name of the lens flare system
  59306. */
  59307. name: string, emitter: any, scene: Scene);
  59308. /**
  59309. * Define if the lens flare system is enabled.
  59310. */
  59311. get isEnabled(): boolean;
  59312. set isEnabled(value: boolean);
  59313. /**
  59314. * Get the scene the effects belongs to.
  59315. * @returns the scene holding the lens flare system
  59316. */
  59317. getScene(): Scene;
  59318. /**
  59319. * Get the emitter of the lens flare system.
  59320. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59321. * @returns the emitter of the lens flare system
  59322. */
  59323. getEmitter(): any;
  59324. /**
  59325. * Set the emitter of the lens flare system.
  59326. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59327. * @param newEmitter Define the new emitter of the system
  59328. */
  59329. setEmitter(newEmitter: any): void;
  59330. /**
  59331. * Get the lens flare system emitter position.
  59332. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59333. * @returns the position
  59334. */
  59335. getEmitterPosition(): Vector3;
  59336. /**
  59337. * @hidden
  59338. */
  59339. computeEffectivePosition(globalViewport: Viewport): boolean;
  59340. /** @hidden */
  59341. _isVisible(): boolean;
  59342. /**
  59343. * @hidden
  59344. */
  59345. render(): boolean;
  59346. /**
  59347. * Dispose and release the lens flare with its associated resources.
  59348. */
  59349. dispose(): void;
  59350. /**
  59351. * Parse a lens flare system from a JSON repressentation
  59352. * @param parsedLensFlareSystem Define the JSON to parse
  59353. * @param scene Define the scene the parsed system should be instantiated in
  59354. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59355. * @returns the parsed system
  59356. */
  59357. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59358. /**
  59359. * Serialize the current Lens Flare System into a JSON representation.
  59360. * @returns the serialized JSON
  59361. */
  59362. serialize(): any;
  59363. }
  59364. }
  59365. declare module BABYLON {
  59366. /**
  59367. * This represents one of the lens effect in a `lensFlareSystem`.
  59368. * It controls one of the indiviual texture used in the effect.
  59369. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59370. */
  59371. export class LensFlare {
  59372. /**
  59373. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59374. */
  59375. size: number;
  59376. /**
  59377. * 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.
  59378. */
  59379. position: number;
  59380. /**
  59381. * Define the lens color.
  59382. */
  59383. color: Color3;
  59384. /**
  59385. * Define the lens texture.
  59386. */
  59387. texture: Nullable<Texture>;
  59388. /**
  59389. * Define the alpha mode to render this particular lens.
  59390. */
  59391. alphaMode: number;
  59392. private _system;
  59393. /**
  59394. * Creates a new Lens Flare.
  59395. * This represents one of the lens effect in a `lensFlareSystem`.
  59396. * It controls one of the indiviual texture used in the effect.
  59397. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59398. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59399. * @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.
  59400. * @param color Define the lens color
  59401. * @param imgUrl Define the lens texture url
  59402. * @param system Define the `lensFlareSystem` this flare is part of
  59403. * @returns The newly created Lens Flare
  59404. */
  59405. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59406. /**
  59407. * Instantiates a new Lens Flare.
  59408. * This represents one of the lens effect in a `lensFlareSystem`.
  59409. * It controls one of the indiviual texture used in the effect.
  59410. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59411. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59412. * @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.
  59413. * @param color Define the lens color
  59414. * @param imgUrl Define the lens texture url
  59415. * @param system Define the `lensFlareSystem` this flare is part of
  59416. */
  59417. constructor(
  59418. /**
  59419. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59420. */
  59421. size: number,
  59422. /**
  59423. * 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.
  59424. */
  59425. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59426. /**
  59427. * Dispose and release the lens flare with its associated resources.
  59428. */
  59429. dispose(): void;
  59430. }
  59431. }
  59432. declare module BABYLON {
  59433. interface AbstractScene {
  59434. /**
  59435. * The list of lens flare system added to the scene
  59436. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59437. */
  59438. lensFlareSystems: Array<LensFlareSystem>;
  59439. /**
  59440. * Removes the given lens flare system from this scene.
  59441. * @param toRemove The lens flare system to remove
  59442. * @returns The index of the removed lens flare system
  59443. */
  59444. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59445. /**
  59446. * Adds the given lens flare system to this scene
  59447. * @param newLensFlareSystem The lens flare system to add
  59448. */
  59449. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59450. /**
  59451. * Gets a lens flare system using its name
  59452. * @param name defines the name to look for
  59453. * @returns the lens flare system or null if not found
  59454. */
  59455. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59456. /**
  59457. * Gets a lens flare system using its id
  59458. * @param id defines the id to look for
  59459. * @returns the lens flare system or null if not found
  59460. */
  59461. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59462. }
  59463. /**
  59464. * Defines the lens flare scene component responsible to manage any lens flares
  59465. * in a given scene.
  59466. */
  59467. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59468. /**
  59469. * The component name helpfull to identify the component in the list of scene components.
  59470. */
  59471. readonly name: string;
  59472. /**
  59473. * The scene the component belongs to.
  59474. */
  59475. scene: Scene;
  59476. /**
  59477. * Creates a new instance of the component for the given scene
  59478. * @param scene Defines the scene to register the component in
  59479. */
  59480. constructor(scene: Scene);
  59481. /**
  59482. * Registers the component in a given scene
  59483. */
  59484. register(): void;
  59485. /**
  59486. * Rebuilds the elements related to this component in case of
  59487. * context lost for instance.
  59488. */
  59489. rebuild(): void;
  59490. /**
  59491. * Adds all the elements from the container to the scene
  59492. * @param container the container holding the elements
  59493. */
  59494. addFromContainer(container: AbstractScene): void;
  59495. /**
  59496. * Removes all the elements in the container from the scene
  59497. * @param container contains the elements to remove
  59498. * @param dispose if the removed element should be disposed (default: false)
  59499. */
  59500. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59501. /**
  59502. * Serializes the component data to the specified json object
  59503. * @param serializationObject The object to serialize to
  59504. */
  59505. serialize(serializationObject: any): void;
  59506. /**
  59507. * Disposes the component and the associated ressources.
  59508. */
  59509. dispose(): void;
  59510. private _draw;
  59511. }
  59512. }
  59513. declare module BABYLON {
  59514. /** @hidden */
  59515. export var depthPixelShader: {
  59516. name: string;
  59517. shader: string;
  59518. };
  59519. }
  59520. declare module BABYLON {
  59521. /** @hidden */
  59522. export var depthVertexShader: {
  59523. name: string;
  59524. shader: string;
  59525. };
  59526. }
  59527. declare module BABYLON {
  59528. /**
  59529. * This represents a depth renderer in Babylon.
  59530. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59531. */
  59532. export class DepthRenderer {
  59533. private _scene;
  59534. private _depthMap;
  59535. private _effect;
  59536. private readonly _storeNonLinearDepth;
  59537. private readonly _clearColor;
  59538. /** Get if the depth renderer is using packed depth or not */
  59539. readonly isPacked: boolean;
  59540. private _cachedDefines;
  59541. private _camera;
  59542. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59543. enabled: boolean;
  59544. /**
  59545. * Specifiess that the depth renderer will only be used within
  59546. * the camera it is created for.
  59547. * This can help forcing its rendering during the camera processing.
  59548. */
  59549. useOnlyInActiveCamera: boolean;
  59550. /** @hidden */
  59551. static _SceneComponentInitialization: (scene: Scene) => void;
  59552. /**
  59553. * Instantiates a depth renderer
  59554. * @param scene The scene the renderer belongs to
  59555. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59556. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59557. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59558. */
  59559. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59560. /**
  59561. * Creates the depth rendering effect and checks if the effect is ready.
  59562. * @param subMesh The submesh to be used to render the depth map of
  59563. * @param useInstances If multiple world instances should be used
  59564. * @returns if the depth renderer is ready to render the depth map
  59565. */
  59566. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59567. /**
  59568. * Gets the texture which the depth map will be written to.
  59569. * @returns The depth map texture
  59570. */
  59571. getDepthMap(): RenderTargetTexture;
  59572. /**
  59573. * Disposes of the depth renderer.
  59574. */
  59575. dispose(): void;
  59576. }
  59577. }
  59578. declare module BABYLON {
  59579. /** @hidden */
  59580. export var minmaxReduxPixelShader: {
  59581. name: string;
  59582. shader: string;
  59583. };
  59584. }
  59585. declare module BABYLON {
  59586. /**
  59587. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59588. * and maximum values from all values of the texture.
  59589. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59590. * The source values are read from the red channel of the texture.
  59591. */
  59592. export class MinMaxReducer {
  59593. /**
  59594. * Observable triggered when the computation has been performed
  59595. */
  59596. onAfterReductionPerformed: Observable<{
  59597. min: number;
  59598. max: number;
  59599. }>;
  59600. protected _camera: Camera;
  59601. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59602. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59603. protected _postProcessManager: PostProcessManager;
  59604. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59605. protected _forceFullscreenViewport: boolean;
  59606. /**
  59607. * Creates a min/max reducer
  59608. * @param camera The camera to use for the post processes
  59609. */
  59610. constructor(camera: Camera);
  59611. /**
  59612. * Gets the texture used to read the values from.
  59613. */
  59614. get sourceTexture(): Nullable<RenderTargetTexture>;
  59615. /**
  59616. * Sets the source texture to read the values from.
  59617. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59618. * because in such textures '1' value must not be taken into account to compute the maximum
  59619. * as this value is used to clear the texture.
  59620. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59621. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59622. * @param depthRedux Indicates if the texture is a depth texture or not
  59623. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59624. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59625. */
  59626. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59627. /**
  59628. * Defines the refresh rate of the computation.
  59629. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59630. */
  59631. get refreshRate(): number;
  59632. set refreshRate(value: number);
  59633. protected _activated: boolean;
  59634. /**
  59635. * Gets the activation status of the reducer
  59636. */
  59637. get activated(): boolean;
  59638. /**
  59639. * Activates the reduction computation.
  59640. * When activated, the observers registered in onAfterReductionPerformed are
  59641. * called after the compuation is performed
  59642. */
  59643. activate(): void;
  59644. /**
  59645. * Deactivates the reduction computation.
  59646. */
  59647. deactivate(): void;
  59648. /**
  59649. * Disposes the min/max reducer
  59650. * @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.
  59651. */
  59652. dispose(disposeAll?: boolean): void;
  59653. }
  59654. }
  59655. declare module BABYLON {
  59656. /**
  59657. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59658. */
  59659. export class DepthReducer extends MinMaxReducer {
  59660. private _depthRenderer;
  59661. private _depthRendererId;
  59662. /**
  59663. * Gets the depth renderer used for the computation.
  59664. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59665. */
  59666. get depthRenderer(): Nullable<DepthRenderer>;
  59667. /**
  59668. * Creates a depth reducer
  59669. * @param camera The camera used to render the depth texture
  59670. */
  59671. constructor(camera: Camera);
  59672. /**
  59673. * Sets the depth renderer to use to generate the depth map
  59674. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59675. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59676. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59677. */
  59678. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59679. /** @hidden */
  59680. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59681. /**
  59682. * Activates the reduction computation.
  59683. * When activated, the observers registered in onAfterReductionPerformed are
  59684. * called after the compuation is performed
  59685. */
  59686. activate(): void;
  59687. /**
  59688. * Deactivates the reduction computation.
  59689. */
  59690. deactivate(): void;
  59691. /**
  59692. * Disposes the depth reducer
  59693. * @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.
  59694. */
  59695. dispose(disposeAll?: boolean): void;
  59696. }
  59697. }
  59698. declare module BABYLON {
  59699. /**
  59700. * A CSM implementation allowing casting shadows on large scenes.
  59701. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59702. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59703. */
  59704. export class CascadedShadowGenerator extends ShadowGenerator {
  59705. private static readonly frustumCornersNDCSpace;
  59706. /**
  59707. * Name of the CSM class
  59708. */
  59709. static CLASSNAME: string;
  59710. /**
  59711. * Defines the default number of cascades used by the CSM.
  59712. */
  59713. static readonly DEFAULT_CASCADES_COUNT: number;
  59714. /**
  59715. * Defines the minimum number of cascades used by the CSM.
  59716. */
  59717. static readonly MIN_CASCADES_COUNT: number;
  59718. /**
  59719. * Defines the maximum number of cascades used by the CSM.
  59720. */
  59721. static readonly MAX_CASCADES_COUNT: number;
  59722. protected _validateFilter(filter: number): number;
  59723. /**
  59724. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59725. */
  59726. penumbraDarkness: number;
  59727. private _numCascades;
  59728. /**
  59729. * Gets or set the number of cascades used by the CSM.
  59730. */
  59731. get numCascades(): number;
  59732. set numCascades(value: number);
  59733. /**
  59734. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59735. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59736. */
  59737. stabilizeCascades: boolean;
  59738. private _freezeShadowCastersBoundingInfo;
  59739. private _freezeShadowCastersBoundingInfoObservable;
  59740. /**
  59741. * Enables or disables the shadow casters bounding info computation.
  59742. * If your shadow casters don't move, you can disable this feature.
  59743. * If it is enabled, the bounding box computation is done every frame.
  59744. */
  59745. get freezeShadowCastersBoundingInfo(): boolean;
  59746. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59747. private _scbiMin;
  59748. private _scbiMax;
  59749. protected _computeShadowCastersBoundingInfo(): void;
  59750. protected _shadowCastersBoundingInfo: BoundingInfo;
  59751. /**
  59752. * Gets or sets the shadow casters bounding info.
  59753. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59754. * so that the system won't overwrite the bounds you provide
  59755. */
  59756. get shadowCastersBoundingInfo(): BoundingInfo;
  59757. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59758. protected _breaksAreDirty: boolean;
  59759. protected _minDistance: number;
  59760. protected _maxDistance: number;
  59761. /**
  59762. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59763. *
  59764. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59765. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59766. * @param min minimal distance for the breaks (default to 0.)
  59767. * @param max maximal distance for the breaks (default to 1.)
  59768. */
  59769. setMinMaxDistance(min: number, max: number): void;
  59770. /** Gets the minimal distance used in the cascade break computation */
  59771. get minDistance(): number;
  59772. /** Gets the maximal distance used in the cascade break computation */
  59773. get maxDistance(): number;
  59774. /**
  59775. * Gets the class name of that object
  59776. * @returns "CascadedShadowGenerator"
  59777. */
  59778. getClassName(): string;
  59779. private _cascadeMinExtents;
  59780. private _cascadeMaxExtents;
  59781. /**
  59782. * Gets a cascade minimum extents
  59783. * @param cascadeIndex index of the cascade
  59784. * @returns the minimum cascade extents
  59785. */
  59786. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59787. /**
  59788. * Gets a cascade maximum extents
  59789. * @param cascadeIndex index of the cascade
  59790. * @returns the maximum cascade extents
  59791. */
  59792. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59793. private _cascades;
  59794. private _currentLayer;
  59795. private _viewSpaceFrustumsZ;
  59796. private _viewMatrices;
  59797. private _projectionMatrices;
  59798. private _transformMatrices;
  59799. private _transformMatricesAsArray;
  59800. private _frustumLengths;
  59801. private _lightSizeUVCorrection;
  59802. private _depthCorrection;
  59803. private _frustumCornersWorldSpace;
  59804. private _frustumCenter;
  59805. private _shadowCameraPos;
  59806. private _shadowMaxZ;
  59807. /**
  59808. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59809. * It defaults to camera.maxZ
  59810. */
  59811. get shadowMaxZ(): number;
  59812. /**
  59813. * Sets the shadow max z distance.
  59814. */
  59815. set shadowMaxZ(value: number);
  59816. protected _debug: boolean;
  59817. /**
  59818. * Gets or sets the debug flag.
  59819. * When enabled, the cascades are materialized by different colors on the screen.
  59820. */
  59821. get debug(): boolean;
  59822. set debug(dbg: boolean);
  59823. private _depthClamp;
  59824. /**
  59825. * Gets or sets the depth clamping value.
  59826. *
  59827. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59828. * to account for the shadow casters far away.
  59829. *
  59830. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59831. */
  59832. get depthClamp(): boolean;
  59833. set depthClamp(value: boolean);
  59834. private _cascadeBlendPercentage;
  59835. /**
  59836. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59837. * It defaults to 0.1 (10% blending).
  59838. */
  59839. get cascadeBlendPercentage(): number;
  59840. set cascadeBlendPercentage(value: number);
  59841. private _lambda;
  59842. /**
  59843. * Gets or set the lambda parameter.
  59844. * This parameter is used to split the camera frustum and create the cascades.
  59845. * 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.
  59846. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59847. */
  59848. get lambda(): number;
  59849. set lambda(value: number);
  59850. /**
  59851. * Gets the view matrix corresponding to a given cascade
  59852. * @param cascadeNum cascade to retrieve the view matrix from
  59853. * @returns the cascade view matrix
  59854. */
  59855. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59856. /**
  59857. * Gets the projection matrix corresponding to a given cascade
  59858. * @param cascadeNum cascade to retrieve the projection matrix from
  59859. * @returns the cascade projection matrix
  59860. */
  59861. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59862. /**
  59863. * Gets the transformation matrix corresponding to a given cascade
  59864. * @param cascadeNum cascade to retrieve the transformation matrix from
  59865. * @returns the cascade transformation matrix
  59866. */
  59867. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59868. private _depthRenderer;
  59869. /**
  59870. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59871. *
  59872. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59873. *
  59874. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59875. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59876. * @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
  59877. */
  59878. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59879. private _depthReducer;
  59880. private _autoCalcDepthBounds;
  59881. /**
  59882. * Gets or sets the autoCalcDepthBounds property.
  59883. *
  59884. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59885. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59886. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59887. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59888. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59889. */
  59890. get autoCalcDepthBounds(): boolean;
  59891. set autoCalcDepthBounds(value: boolean);
  59892. /**
  59893. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59894. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59895. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59896. * for setting the refresh rate on the renderer yourself!
  59897. */
  59898. get autoCalcDepthBoundsRefreshRate(): number;
  59899. set autoCalcDepthBoundsRefreshRate(value: number);
  59900. /**
  59901. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59902. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59903. * you change the camera near/far planes!
  59904. */
  59905. splitFrustum(): void;
  59906. private _splitFrustum;
  59907. private _computeMatrices;
  59908. private _computeFrustumInWorldSpace;
  59909. private _computeCascadeFrustum;
  59910. /**
  59911. * Support test.
  59912. */
  59913. static get IsSupported(): boolean;
  59914. /** @hidden */
  59915. static _SceneComponentInitialization: (scene: Scene) => void;
  59916. /**
  59917. * Creates a Cascaded Shadow Generator object.
  59918. * A ShadowGenerator is the required tool to use the shadows.
  59919. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59920. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59921. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59922. * @param light The directional light object generating the shadows.
  59923. * @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.
  59924. */
  59925. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59926. protected _initializeGenerator(): void;
  59927. protected _createTargetRenderTexture(): void;
  59928. protected _initializeShadowMap(): void;
  59929. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59930. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59931. /**
  59932. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59933. * @param defines Defines of the material we want to update
  59934. * @param lightIndex Index of the light in the enabled light list of the material
  59935. */
  59936. prepareDefines(defines: any, lightIndex: number): void;
  59937. /**
  59938. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59939. * defined in the generator but impacting the effect).
  59940. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59941. * @param effect The effect we are binfing the information for
  59942. */
  59943. bindShadowLight(lightIndex: string, effect: Effect): void;
  59944. /**
  59945. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59946. * (eq to view projection * shadow projection matrices)
  59947. * @returns The transform matrix used to create the shadow map
  59948. */
  59949. getTransformMatrix(): Matrix;
  59950. /**
  59951. * Disposes the ShadowGenerator.
  59952. * Returns nothing.
  59953. */
  59954. dispose(): void;
  59955. /**
  59956. * Serializes the shadow generator setup to a json object.
  59957. * @returns The serialized JSON object
  59958. */
  59959. serialize(): any;
  59960. /**
  59961. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59962. * @param parsedShadowGenerator The JSON object to parse
  59963. * @param scene The scene to create the shadow map for
  59964. * @returns The parsed shadow generator
  59965. */
  59966. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59967. }
  59968. }
  59969. declare module BABYLON {
  59970. /**
  59971. * Defines the shadow generator component responsible to manage any shadow generators
  59972. * in a given scene.
  59973. */
  59974. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59975. /**
  59976. * The component name helpfull to identify the component in the list of scene components.
  59977. */
  59978. readonly name: string;
  59979. /**
  59980. * The scene the component belongs to.
  59981. */
  59982. scene: Scene;
  59983. /**
  59984. * Creates a new instance of the component for the given scene
  59985. * @param scene Defines the scene to register the component in
  59986. */
  59987. constructor(scene: Scene);
  59988. /**
  59989. * Registers the component in a given scene
  59990. */
  59991. register(): void;
  59992. /**
  59993. * Rebuilds the elements related to this component in case of
  59994. * context lost for instance.
  59995. */
  59996. rebuild(): void;
  59997. /**
  59998. * Serializes the component data to the specified json object
  59999. * @param serializationObject The object to serialize to
  60000. */
  60001. serialize(serializationObject: any): void;
  60002. /**
  60003. * Adds all the elements from the container to the scene
  60004. * @param container the container holding the elements
  60005. */
  60006. addFromContainer(container: AbstractScene): void;
  60007. /**
  60008. * Removes all the elements in the container from the scene
  60009. * @param container contains the elements to remove
  60010. * @param dispose if the removed element should be disposed (default: false)
  60011. */
  60012. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60013. /**
  60014. * Rebuilds the elements related to this component in case of
  60015. * context lost for instance.
  60016. */
  60017. dispose(): void;
  60018. private _gatherRenderTargets;
  60019. }
  60020. }
  60021. declare module BABYLON {
  60022. /**
  60023. * A point light is a light defined by an unique point in world space.
  60024. * The light is emitted in every direction from this point.
  60025. * A good example of a point light is a standard light bulb.
  60026. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60027. */
  60028. export class PointLight extends ShadowLight {
  60029. private _shadowAngle;
  60030. /**
  60031. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60032. * This specifies what angle the shadow will use to be created.
  60033. *
  60034. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60035. */
  60036. get shadowAngle(): number;
  60037. /**
  60038. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60039. * This specifies what angle the shadow will use to be created.
  60040. *
  60041. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60042. */
  60043. set shadowAngle(value: number);
  60044. /**
  60045. * Gets the direction if it has been set.
  60046. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60047. */
  60048. get direction(): Vector3;
  60049. /**
  60050. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60051. */
  60052. set direction(value: Vector3);
  60053. /**
  60054. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60055. * A PointLight emits the light in every direction.
  60056. * It can cast shadows.
  60057. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60058. * ```javascript
  60059. * var pointLight = new PointLight("pl", camera.position, scene);
  60060. * ```
  60061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60062. * @param name The light friendly name
  60063. * @param position The position of the point light in the scene
  60064. * @param scene The scene the lights belongs to
  60065. */
  60066. constructor(name: string, position: Vector3, scene: Scene);
  60067. /**
  60068. * Returns the string "PointLight"
  60069. * @returns the class name
  60070. */
  60071. getClassName(): string;
  60072. /**
  60073. * Returns the integer 0.
  60074. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60075. */
  60076. getTypeID(): number;
  60077. /**
  60078. * Specifies wether or not the shadowmap should be a cube texture.
  60079. * @returns true if the shadowmap needs to be a cube texture.
  60080. */
  60081. needCube(): boolean;
  60082. /**
  60083. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60084. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60085. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60086. */
  60087. getShadowDirection(faceIndex?: number): Vector3;
  60088. /**
  60089. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60090. * - fov = PI / 2
  60091. * - aspect ratio : 1.0
  60092. * - z-near and far equal to the active camera minZ and maxZ.
  60093. * Returns the PointLight.
  60094. */
  60095. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60096. protected _buildUniformLayout(): void;
  60097. /**
  60098. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60099. * @param effect The effect to update
  60100. * @param lightIndex The index of the light in the effect to update
  60101. * @returns The point light
  60102. */
  60103. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60104. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60105. /**
  60106. * Prepares the list of defines specific to the light type.
  60107. * @param defines the list of defines
  60108. * @param lightIndex defines the index of the light for the effect
  60109. */
  60110. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60111. }
  60112. }
  60113. declare module BABYLON {
  60114. /**
  60115. * Header information of HDR texture files.
  60116. */
  60117. export interface HDRInfo {
  60118. /**
  60119. * The height of the texture in pixels.
  60120. */
  60121. height: number;
  60122. /**
  60123. * The width of the texture in pixels.
  60124. */
  60125. width: number;
  60126. /**
  60127. * The index of the beginning of the data in the binary file.
  60128. */
  60129. dataPosition: number;
  60130. }
  60131. /**
  60132. * This groups tools to convert HDR texture to native colors array.
  60133. */
  60134. export class HDRTools {
  60135. private static Ldexp;
  60136. private static Rgbe2float;
  60137. private static readStringLine;
  60138. /**
  60139. * Reads header information from an RGBE texture stored in a native array.
  60140. * More information on this format are available here:
  60141. * https://en.wikipedia.org/wiki/RGBE_image_format
  60142. *
  60143. * @param uint8array The binary file stored in native array.
  60144. * @return The header information.
  60145. */
  60146. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60147. /**
  60148. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60149. * This RGBE texture needs to store the information as a panorama.
  60150. *
  60151. * More information on this format are available here:
  60152. * https://en.wikipedia.org/wiki/RGBE_image_format
  60153. *
  60154. * @param buffer The binary file stored in an array buffer.
  60155. * @param size The expected size of the extracted cubemap.
  60156. * @return The Cube Map information.
  60157. */
  60158. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60159. /**
  60160. * Returns the pixels data extracted from an RGBE texture.
  60161. * This pixels will be stored left to right up to down in the R G B order in one array.
  60162. *
  60163. * More information on this format are available here:
  60164. * https://en.wikipedia.org/wiki/RGBE_image_format
  60165. *
  60166. * @param uint8array The binary file stored in an array buffer.
  60167. * @param hdrInfo The header information of the file.
  60168. * @return The pixels data in RGB right to left up to down order.
  60169. */
  60170. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60171. private static RGBE_ReadPixels_RLE;
  60172. private static RGBE_ReadPixels_NOT_RLE;
  60173. }
  60174. }
  60175. declare module BABYLON {
  60176. /**
  60177. * Effect Render Options
  60178. */
  60179. export interface IEffectRendererOptions {
  60180. /**
  60181. * Defines the vertices positions.
  60182. */
  60183. positions?: number[];
  60184. /**
  60185. * Defines the indices.
  60186. */
  60187. indices?: number[];
  60188. }
  60189. /**
  60190. * Helper class to render one or more effects.
  60191. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60192. */
  60193. export class EffectRenderer {
  60194. private engine;
  60195. private static _DefaultOptions;
  60196. private _vertexBuffers;
  60197. private _indexBuffer;
  60198. private _fullscreenViewport;
  60199. /**
  60200. * Creates an effect renderer
  60201. * @param engine the engine to use for rendering
  60202. * @param options defines the options of the effect renderer
  60203. */
  60204. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60205. /**
  60206. * Sets the current viewport in normalized coordinates 0-1
  60207. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60208. */
  60209. setViewport(viewport?: Viewport): void;
  60210. /**
  60211. * Binds the embedded attributes buffer to the effect.
  60212. * @param effect Defines the effect to bind the attributes for
  60213. */
  60214. bindBuffers(effect: Effect): void;
  60215. /**
  60216. * Sets the current effect wrapper to use during draw.
  60217. * The effect needs to be ready before calling this api.
  60218. * This also sets the default full screen position attribute.
  60219. * @param effectWrapper Defines the effect to draw with
  60220. */
  60221. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60222. /**
  60223. * Restores engine states
  60224. */
  60225. restoreStates(): void;
  60226. /**
  60227. * Draws a full screen quad.
  60228. */
  60229. draw(): void;
  60230. private isRenderTargetTexture;
  60231. /**
  60232. * renders one or more effects to a specified texture
  60233. * @param effectWrapper the effect to renderer
  60234. * @param outputTexture texture to draw to, if null it will render to the screen.
  60235. */
  60236. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60237. /**
  60238. * Disposes of the effect renderer
  60239. */
  60240. dispose(): void;
  60241. }
  60242. /**
  60243. * Options to create an EffectWrapper
  60244. */
  60245. interface EffectWrapperCreationOptions {
  60246. /**
  60247. * Engine to use to create the effect
  60248. */
  60249. engine: ThinEngine;
  60250. /**
  60251. * Fragment shader for the effect
  60252. */
  60253. fragmentShader: string;
  60254. /**
  60255. * Use the shader store instead of direct source code
  60256. */
  60257. useShaderStore?: boolean;
  60258. /**
  60259. * Vertex shader for the effect
  60260. */
  60261. vertexShader?: string;
  60262. /**
  60263. * Attributes to use in the shader
  60264. */
  60265. attributeNames?: Array<string>;
  60266. /**
  60267. * Uniforms to use in the shader
  60268. */
  60269. uniformNames?: Array<string>;
  60270. /**
  60271. * Texture sampler names to use in the shader
  60272. */
  60273. samplerNames?: Array<string>;
  60274. /**
  60275. * Defines to use in the shader
  60276. */
  60277. defines?: Array<string>;
  60278. /**
  60279. * Callback when effect is compiled
  60280. */
  60281. onCompiled?: Nullable<(effect: Effect) => void>;
  60282. /**
  60283. * The friendly name of the effect displayed in Spector.
  60284. */
  60285. name?: string;
  60286. }
  60287. /**
  60288. * Wraps an effect to be used for rendering
  60289. */
  60290. export class EffectWrapper {
  60291. /**
  60292. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60293. */
  60294. onApplyObservable: Observable<{}>;
  60295. /**
  60296. * The underlying effect
  60297. */
  60298. effect: Effect;
  60299. /**
  60300. * Creates an effect to be renderer
  60301. * @param creationOptions options to create the effect
  60302. */
  60303. constructor(creationOptions: EffectWrapperCreationOptions);
  60304. /**
  60305. * Disposes of the effect wrapper
  60306. */
  60307. dispose(): void;
  60308. }
  60309. }
  60310. declare module BABYLON {
  60311. /** @hidden */
  60312. export var hdrFilteringVertexShader: {
  60313. name: string;
  60314. shader: string;
  60315. };
  60316. }
  60317. declare module BABYLON {
  60318. /** @hidden */
  60319. export var hdrFilteringPixelShader: {
  60320. name: string;
  60321. shader: string;
  60322. };
  60323. }
  60324. declare module BABYLON {
  60325. /**
  60326. * Options for texture filtering
  60327. */
  60328. interface IHDRFilteringOptions {
  60329. /**
  60330. * Scales pixel intensity for the input HDR map.
  60331. */
  60332. hdrScale?: number;
  60333. /**
  60334. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60335. */
  60336. quality?: number;
  60337. }
  60338. /**
  60339. * Filters HDR maps to get correct renderings of PBR reflections
  60340. */
  60341. export class HDRFiltering {
  60342. private _engine;
  60343. private _effectRenderer;
  60344. private _effectWrapper;
  60345. private _lodGenerationOffset;
  60346. private _lodGenerationScale;
  60347. /**
  60348. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60349. * you care about baking speed.
  60350. */
  60351. quality: number;
  60352. /**
  60353. * Scales pixel intensity for the input HDR map.
  60354. */
  60355. hdrScale: number;
  60356. /**
  60357. * Instantiates HDR filter for reflection maps
  60358. *
  60359. * @param engine Thin engine
  60360. * @param options Options
  60361. */
  60362. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60363. private _createRenderTarget;
  60364. private _prefilterInternal;
  60365. private _createEffect;
  60366. /**
  60367. * Get a value indicating if the filter is ready to be used
  60368. * @param texture Texture to filter
  60369. * @returns true if the filter is ready
  60370. */
  60371. isReady(texture: BaseTexture): boolean;
  60372. /**
  60373. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60374. * Prefiltering will be invoked at the end of next rendering pass.
  60375. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60376. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60377. * @param texture Texture to filter
  60378. * @param onFinished Callback when filtering is done
  60379. * @return Promise called when prefiltering is done
  60380. */
  60381. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60382. }
  60383. }
  60384. declare module BABYLON {
  60385. /**
  60386. * This represents a texture coming from an HDR input.
  60387. *
  60388. * The only supported format is currently panorama picture stored in RGBE format.
  60389. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60390. */
  60391. export class HDRCubeTexture extends BaseTexture {
  60392. private static _facesMapping;
  60393. private _generateHarmonics;
  60394. private _noMipmap;
  60395. private _prefilterOnLoad;
  60396. private _textureMatrix;
  60397. private _size;
  60398. private _onLoad;
  60399. private _onError;
  60400. /**
  60401. * The texture URL.
  60402. */
  60403. url: string;
  60404. protected _isBlocking: boolean;
  60405. /**
  60406. * Sets wether or not the texture is blocking during loading.
  60407. */
  60408. set isBlocking(value: boolean);
  60409. /**
  60410. * Gets wether or not the texture is blocking during loading.
  60411. */
  60412. get isBlocking(): boolean;
  60413. protected _rotationY: number;
  60414. /**
  60415. * Sets texture matrix rotation angle around Y axis in radians.
  60416. */
  60417. set rotationY(value: number);
  60418. /**
  60419. * Gets texture matrix rotation angle around Y axis radians.
  60420. */
  60421. get rotationY(): number;
  60422. /**
  60423. * Gets or sets the center of the bounding box associated with the cube texture
  60424. * It must define where the camera used to render the texture was set
  60425. */
  60426. boundingBoxPosition: Vector3;
  60427. private _boundingBoxSize;
  60428. /**
  60429. * Gets or sets the size of the bounding box associated with the cube texture
  60430. * When defined, the cubemap will switch to local mode
  60431. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60432. * @example https://www.babylonjs-playground.com/#RNASML
  60433. */
  60434. set boundingBoxSize(value: Vector3);
  60435. get boundingBoxSize(): Vector3;
  60436. /**
  60437. * Instantiates an HDRTexture from the following parameters.
  60438. *
  60439. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60440. * @param sceneOrEngine The scene or engine the texture will be used in
  60441. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60442. * @param noMipmap Forces to not generate the mipmap if true
  60443. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60444. * @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)
  60445. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60446. */
  60447. 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>);
  60448. /**
  60449. * Get the current class name of the texture useful for serialization or dynamic coding.
  60450. * @returns "HDRCubeTexture"
  60451. */
  60452. getClassName(): string;
  60453. /**
  60454. * Occurs when the file is raw .hdr file.
  60455. */
  60456. private loadTexture;
  60457. clone(): HDRCubeTexture;
  60458. delayLoad(): void;
  60459. /**
  60460. * Get the texture reflection matrix used to rotate/transform the reflection.
  60461. * @returns the reflection matrix
  60462. */
  60463. getReflectionTextureMatrix(): Matrix;
  60464. /**
  60465. * Set the texture reflection matrix used to rotate/transform the reflection.
  60466. * @param value Define the reflection matrix to set
  60467. */
  60468. setReflectionTextureMatrix(value: Matrix): void;
  60469. /**
  60470. * Parses a JSON representation of an HDR Texture in order to create the texture
  60471. * @param parsedTexture Define the JSON representation
  60472. * @param scene Define the scene the texture should be created in
  60473. * @param rootUrl Define the root url in case we need to load relative dependencies
  60474. * @returns the newly created texture after parsing
  60475. */
  60476. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60477. serialize(): any;
  60478. }
  60479. }
  60480. declare module BABYLON {
  60481. /**
  60482. * Class used to control physics engine
  60483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60484. */
  60485. export class PhysicsEngine implements IPhysicsEngine {
  60486. private _physicsPlugin;
  60487. /**
  60488. * Global value used to control the smallest number supported by the simulation
  60489. */
  60490. static Epsilon: number;
  60491. private _impostors;
  60492. private _joints;
  60493. private _subTimeStep;
  60494. /**
  60495. * Gets the gravity vector used by the simulation
  60496. */
  60497. gravity: Vector3;
  60498. /**
  60499. * Factory used to create the default physics plugin.
  60500. * @returns The default physics plugin
  60501. */
  60502. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60503. /**
  60504. * Creates a new Physics Engine
  60505. * @param gravity defines the gravity vector used by the simulation
  60506. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60507. */
  60508. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60509. /**
  60510. * Sets the gravity vector used by the simulation
  60511. * @param gravity defines the gravity vector to use
  60512. */
  60513. setGravity(gravity: Vector3): void;
  60514. /**
  60515. * Set the time step of the physics engine.
  60516. * Default is 1/60.
  60517. * To slow it down, enter 1/600 for example.
  60518. * To speed it up, 1/30
  60519. * @param newTimeStep defines the new timestep to apply to this world.
  60520. */
  60521. setTimeStep(newTimeStep?: number): void;
  60522. /**
  60523. * Get the time step of the physics engine.
  60524. * @returns the current time step
  60525. */
  60526. getTimeStep(): number;
  60527. /**
  60528. * Set the sub time step of the physics engine.
  60529. * Default is 0 meaning there is no sub steps
  60530. * To increase physics resolution precision, set a small value (like 1 ms)
  60531. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60532. */
  60533. setSubTimeStep(subTimeStep?: number): void;
  60534. /**
  60535. * Get the sub time step of the physics engine.
  60536. * @returns the current sub time step
  60537. */
  60538. getSubTimeStep(): number;
  60539. /**
  60540. * Release all resources
  60541. */
  60542. dispose(): void;
  60543. /**
  60544. * Gets the name of the current physics plugin
  60545. * @returns the name of the plugin
  60546. */
  60547. getPhysicsPluginName(): string;
  60548. /**
  60549. * Adding a new impostor for the impostor tracking.
  60550. * This will be done by the impostor itself.
  60551. * @param impostor the impostor to add
  60552. */
  60553. addImpostor(impostor: PhysicsImpostor): void;
  60554. /**
  60555. * Remove an impostor from the engine.
  60556. * This impostor and its mesh will not longer be updated by the physics engine.
  60557. * @param impostor the impostor to remove
  60558. */
  60559. removeImpostor(impostor: PhysicsImpostor): void;
  60560. /**
  60561. * Add a joint to the physics engine
  60562. * @param mainImpostor defines the main impostor to which the joint is added.
  60563. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60564. * @param joint defines the joint that will connect both impostors.
  60565. */
  60566. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60567. /**
  60568. * Removes a joint from the simulation
  60569. * @param mainImpostor defines the impostor used with the joint
  60570. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60571. * @param joint defines the joint to remove
  60572. */
  60573. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60574. /**
  60575. * Called by the scene. No need to call it.
  60576. * @param delta defines the timespam between frames
  60577. */
  60578. _step(delta: number): void;
  60579. /**
  60580. * Gets the current plugin used to run the simulation
  60581. * @returns current plugin
  60582. */
  60583. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60584. /**
  60585. * Gets the list of physic impostors
  60586. * @returns an array of PhysicsImpostor
  60587. */
  60588. getImpostors(): Array<PhysicsImpostor>;
  60589. /**
  60590. * Gets the impostor for a physics enabled object
  60591. * @param object defines the object impersonated by the impostor
  60592. * @returns the PhysicsImpostor or null if not found
  60593. */
  60594. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60595. /**
  60596. * Gets the impostor for a physics body object
  60597. * @param body defines physics body used by the impostor
  60598. * @returns the PhysicsImpostor or null if not found
  60599. */
  60600. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60601. /**
  60602. * Does a raycast in the physics world
  60603. * @param from when should the ray start?
  60604. * @param to when should the ray end?
  60605. * @returns PhysicsRaycastResult
  60606. */
  60607. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60608. }
  60609. }
  60610. declare module BABYLON {
  60611. /** @hidden */
  60612. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60613. private _useDeltaForWorldStep;
  60614. world: any;
  60615. name: string;
  60616. private _physicsMaterials;
  60617. private _fixedTimeStep;
  60618. private _cannonRaycastResult;
  60619. private _raycastResult;
  60620. private _physicsBodysToRemoveAfterStep;
  60621. private _firstFrame;
  60622. BJSCANNON: any;
  60623. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60624. setGravity(gravity: Vector3): void;
  60625. setTimeStep(timeStep: number): void;
  60626. getTimeStep(): number;
  60627. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60628. private _removeMarkedPhysicsBodiesFromWorld;
  60629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60630. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60632. private _processChildMeshes;
  60633. removePhysicsBody(impostor: PhysicsImpostor): void;
  60634. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60635. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60636. private _addMaterial;
  60637. private _checkWithEpsilon;
  60638. private _createShape;
  60639. private _createHeightmap;
  60640. private _minus90X;
  60641. private _plus90X;
  60642. private _tmpPosition;
  60643. private _tmpDeltaPosition;
  60644. private _tmpUnityRotation;
  60645. private _updatePhysicsBodyTransformation;
  60646. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60647. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60648. isSupported(): boolean;
  60649. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60650. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60651. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60652. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60653. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60654. getBodyMass(impostor: PhysicsImpostor): number;
  60655. getBodyFriction(impostor: PhysicsImpostor): number;
  60656. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60657. getBodyRestitution(impostor: PhysicsImpostor): number;
  60658. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60659. sleepBody(impostor: PhysicsImpostor): void;
  60660. wakeUpBody(impostor: PhysicsImpostor): void;
  60661. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60662. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60663. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60664. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60665. getRadius(impostor: PhysicsImpostor): number;
  60666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60667. dispose(): void;
  60668. private _extendNamespace;
  60669. /**
  60670. * Does a raycast in the physics world
  60671. * @param from when should the ray start?
  60672. * @param to when should the ray end?
  60673. * @returns PhysicsRaycastResult
  60674. */
  60675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60676. }
  60677. }
  60678. declare module BABYLON {
  60679. /** @hidden */
  60680. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60681. private _useDeltaForWorldStep;
  60682. world: any;
  60683. name: string;
  60684. BJSOIMO: any;
  60685. private _raycastResult;
  60686. private _fixedTimeStep;
  60687. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60688. setGravity(gravity: Vector3): void;
  60689. setTimeStep(timeStep: number): void;
  60690. getTimeStep(): number;
  60691. private _tmpImpostorsArray;
  60692. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60693. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60694. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60695. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60696. private _tmpPositionVector;
  60697. removePhysicsBody(impostor: PhysicsImpostor): void;
  60698. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60699. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60700. isSupported(): boolean;
  60701. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60702. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60703. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60704. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60705. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60706. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60707. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60708. getBodyMass(impostor: PhysicsImpostor): number;
  60709. getBodyFriction(impostor: PhysicsImpostor): number;
  60710. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60711. getBodyRestitution(impostor: PhysicsImpostor): number;
  60712. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60713. sleepBody(impostor: PhysicsImpostor): void;
  60714. wakeUpBody(impostor: PhysicsImpostor): void;
  60715. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60716. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60717. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60718. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60719. getRadius(impostor: PhysicsImpostor): number;
  60720. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60721. dispose(): void;
  60722. /**
  60723. * Does a raycast in the physics world
  60724. * @param from when should the ray start?
  60725. * @param to when should the ray end?
  60726. * @returns PhysicsRaycastResult
  60727. */
  60728. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60729. }
  60730. }
  60731. declare module BABYLON {
  60732. /**
  60733. * AmmoJS Physics plugin
  60734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60735. * @see https://github.com/kripken/ammo.js/
  60736. */
  60737. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60738. private _useDeltaForWorldStep;
  60739. /**
  60740. * Reference to the Ammo library
  60741. */
  60742. bjsAMMO: any;
  60743. /**
  60744. * Created ammoJS world which physics bodies are added to
  60745. */
  60746. world: any;
  60747. /**
  60748. * Name of the plugin
  60749. */
  60750. name: string;
  60751. private _timeStep;
  60752. private _fixedTimeStep;
  60753. private _maxSteps;
  60754. private _tmpQuaternion;
  60755. private _tmpAmmoTransform;
  60756. private _tmpAmmoQuaternion;
  60757. private _tmpAmmoConcreteContactResultCallback;
  60758. private _collisionConfiguration;
  60759. private _dispatcher;
  60760. private _overlappingPairCache;
  60761. private _solver;
  60762. private _softBodySolver;
  60763. private _tmpAmmoVectorA;
  60764. private _tmpAmmoVectorB;
  60765. private _tmpAmmoVectorC;
  60766. private _tmpAmmoVectorD;
  60767. private _tmpContactCallbackResult;
  60768. private _tmpAmmoVectorRCA;
  60769. private _tmpAmmoVectorRCB;
  60770. private _raycastResult;
  60771. private static readonly DISABLE_COLLISION_FLAG;
  60772. private static readonly KINEMATIC_FLAG;
  60773. private static readonly DISABLE_DEACTIVATION_FLAG;
  60774. /**
  60775. * Initializes the ammoJS plugin
  60776. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60777. * @param ammoInjection can be used to inject your own ammo reference
  60778. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60779. */
  60780. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60781. /**
  60782. * Sets the gravity of the physics world (m/(s^2))
  60783. * @param gravity Gravity to set
  60784. */
  60785. setGravity(gravity: Vector3): void;
  60786. /**
  60787. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60788. * @param timeStep timestep to use in seconds
  60789. */
  60790. setTimeStep(timeStep: number): void;
  60791. /**
  60792. * 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)
  60793. * @param fixedTimeStep fixedTimeStep to use in seconds
  60794. */
  60795. setFixedTimeStep(fixedTimeStep: number): void;
  60796. /**
  60797. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60798. * @param maxSteps the maximum number of steps by the physics engine per frame
  60799. */
  60800. setMaxSteps(maxSteps: number): void;
  60801. /**
  60802. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60803. * @returns the current timestep in seconds
  60804. */
  60805. getTimeStep(): number;
  60806. /**
  60807. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60808. */
  60809. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60810. private _isImpostorInContact;
  60811. private _isImpostorPairInContact;
  60812. private _stepSimulation;
  60813. /**
  60814. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60815. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60816. * After the step the babylon meshes are set to the position of the physics imposters
  60817. * @param delta amount of time to step forward
  60818. * @param impostors array of imposters to update before/after the step
  60819. */
  60820. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60821. /**
  60822. * Update babylon mesh to match physics world object
  60823. * @param impostor imposter to match
  60824. */
  60825. private _afterSoftStep;
  60826. /**
  60827. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60828. * @param impostor imposter to match
  60829. */
  60830. private _ropeStep;
  60831. /**
  60832. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60833. * @param impostor imposter to match
  60834. */
  60835. private _softbodyOrClothStep;
  60836. private _tmpMatrix;
  60837. /**
  60838. * Applies an impulse on the imposter
  60839. * @param impostor imposter to apply impulse to
  60840. * @param force amount of force to be applied to the imposter
  60841. * @param contactPoint the location to apply the impulse on the imposter
  60842. */
  60843. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60844. /**
  60845. * Applies a force on the imposter
  60846. * @param impostor imposter to apply force
  60847. * @param force amount of force to be applied to the imposter
  60848. * @param contactPoint the location to apply the force on the imposter
  60849. */
  60850. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60851. /**
  60852. * Creates a physics body using the plugin
  60853. * @param impostor the imposter to create the physics body on
  60854. */
  60855. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60856. /**
  60857. * Removes the physics body from the imposter and disposes of the body's memory
  60858. * @param impostor imposter to remove the physics body from
  60859. */
  60860. removePhysicsBody(impostor: PhysicsImpostor): void;
  60861. /**
  60862. * Generates a joint
  60863. * @param impostorJoint the imposter joint to create the joint with
  60864. */
  60865. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60866. /**
  60867. * Removes a joint
  60868. * @param impostorJoint the imposter joint to remove the joint from
  60869. */
  60870. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60871. private _addMeshVerts;
  60872. /**
  60873. * Initialise the soft body vertices to match its object's (mesh) vertices
  60874. * Softbody vertices (nodes) are in world space and to match this
  60875. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60876. * @param impostor to create the softbody for
  60877. */
  60878. private _softVertexData;
  60879. /**
  60880. * Create an impostor's soft body
  60881. * @param impostor to create the softbody for
  60882. */
  60883. private _createSoftbody;
  60884. /**
  60885. * Create cloth for an impostor
  60886. * @param impostor to create the softbody for
  60887. */
  60888. private _createCloth;
  60889. /**
  60890. * Create rope for an impostor
  60891. * @param impostor to create the softbody for
  60892. */
  60893. private _createRope;
  60894. /**
  60895. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60896. * @param impostor to create the custom physics shape for
  60897. */
  60898. private _createCustom;
  60899. private _addHullVerts;
  60900. private _createShape;
  60901. /**
  60902. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60903. * @param impostor imposter containing the physics body and babylon object
  60904. */
  60905. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60906. /**
  60907. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60908. * @param impostor imposter containing the physics body and babylon object
  60909. * @param newPosition new position
  60910. * @param newRotation new rotation
  60911. */
  60912. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60913. /**
  60914. * If this plugin is supported
  60915. * @returns true if its supported
  60916. */
  60917. isSupported(): boolean;
  60918. /**
  60919. * Sets the linear velocity of the physics body
  60920. * @param impostor imposter to set the velocity on
  60921. * @param velocity velocity to set
  60922. */
  60923. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60924. /**
  60925. * Sets the angular velocity of the physics body
  60926. * @param impostor imposter to set the velocity on
  60927. * @param velocity velocity to set
  60928. */
  60929. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60930. /**
  60931. * gets the linear velocity
  60932. * @param impostor imposter to get linear velocity from
  60933. * @returns linear velocity
  60934. */
  60935. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60936. /**
  60937. * gets the angular velocity
  60938. * @param impostor imposter to get angular velocity from
  60939. * @returns angular velocity
  60940. */
  60941. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60942. /**
  60943. * Sets the mass of physics body
  60944. * @param impostor imposter to set the mass on
  60945. * @param mass mass to set
  60946. */
  60947. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60948. /**
  60949. * Gets the mass of the physics body
  60950. * @param impostor imposter to get the mass from
  60951. * @returns mass
  60952. */
  60953. getBodyMass(impostor: PhysicsImpostor): number;
  60954. /**
  60955. * Gets friction of the impostor
  60956. * @param impostor impostor to get friction from
  60957. * @returns friction value
  60958. */
  60959. getBodyFriction(impostor: PhysicsImpostor): number;
  60960. /**
  60961. * Sets friction of the impostor
  60962. * @param impostor impostor to set friction on
  60963. * @param friction friction value
  60964. */
  60965. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60966. /**
  60967. * Gets restitution of the impostor
  60968. * @param impostor impostor to get restitution from
  60969. * @returns restitution value
  60970. */
  60971. getBodyRestitution(impostor: PhysicsImpostor): number;
  60972. /**
  60973. * Sets resitution of the impostor
  60974. * @param impostor impostor to set resitution on
  60975. * @param restitution resitution value
  60976. */
  60977. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60978. /**
  60979. * Gets pressure inside the impostor
  60980. * @param impostor impostor to get pressure from
  60981. * @returns pressure value
  60982. */
  60983. getBodyPressure(impostor: PhysicsImpostor): number;
  60984. /**
  60985. * Sets pressure inside a soft body impostor
  60986. * Cloth and rope must remain 0 pressure
  60987. * @param impostor impostor to set pressure on
  60988. * @param pressure pressure value
  60989. */
  60990. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60991. /**
  60992. * Gets stiffness of the impostor
  60993. * @param impostor impostor to get stiffness from
  60994. * @returns pressure value
  60995. */
  60996. getBodyStiffness(impostor: PhysicsImpostor): number;
  60997. /**
  60998. * Sets stiffness of the impostor
  60999. * @param impostor impostor to set stiffness on
  61000. * @param stiffness stiffness value from 0 to 1
  61001. */
  61002. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61003. /**
  61004. * Gets velocityIterations of the impostor
  61005. * @param impostor impostor to get velocity iterations from
  61006. * @returns velocityIterations value
  61007. */
  61008. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61009. /**
  61010. * Sets velocityIterations of the impostor
  61011. * @param impostor impostor to set velocity iterations on
  61012. * @param velocityIterations velocityIterations value
  61013. */
  61014. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61015. /**
  61016. * Gets positionIterations of the impostor
  61017. * @param impostor impostor to get position iterations from
  61018. * @returns positionIterations value
  61019. */
  61020. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61021. /**
  61022. * Sets positionIterations of the impostor
  61023. * @param impostor impostor to set position on
  61024. * @param positionIterations positionIterations value
  61025. */
  61026. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61027. /**
  61028. * Append an anchor to a cloth object
  61029. * @param impostor is the cloth impostor to add anchor to
  61030. * @param otherImpostor is the rigid impostor to anchor to
  61031. * @param width ratio across width from 0 to 1
  61032. * @param height ratio up height from 0 to 1
  61033. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61034. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61035. */
  61036. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61037. /**
  61038. * Append an hook to a rope object
  61039. * @param impostor is the rope impostor to add hook to
  61040. * @param otherImpostor is the rigid impostor to hook to
  61041. * @param length ratio along the rope from 0 to 1
  61042. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61043. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61044. */
  61045. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61046. /**
  61047. * Sleeps the physics body and stops it from being active
  61048. * @param impostor impostor to sleep
  61049. */
  61050. sleepBody(impostor: PhysicsImpostor): void;
  61051. /**
  61052. * Activates the physics body
  61053. * @param impostor impostor to activate
  61054. */
  61055. wakeUpBody(impostor: PhysicsImpostor): void;
  61056. /**
  61057. * Updates the distance parameters of the joint
  61058. * @param joint joint to update
  61059. * @param maxDistance maximum distance of the joint
  61060. * @param minDistance minimum distance of the joint
  61061. */
  61062. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61063. /**
  61064. * Sets a motor on the joint
  61065. * @param joint joint to set motor on
  61066. * @param speed speed of the motor
  61067. * @param maxForce maximum force of the motor
  61068. * @param motorIndex index of the motor
  61069. */
  61070. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61071. /**
  61072. * Sets the motors limit
  61073. * @param joint joint to set limit on
  61074. * @param upperLimit upper limit
  61075. * @param lowerLimit lower limit
  61076. */
  61077. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61078. /**
  61079. * Syncs the position and rotation of a mesh with the impostor
  61080. * @param mesh mesh to sync
  61081. * @param impostor impostor to update the mesh with
  61082. */
  61083. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61084. /**
  61085. * Gets the radius of the impostor
  61086. * @param impostor impostor to get radius from
  61087. * @returns the radius
  61088. */
  61089. getRadius(impostor: PhysicsImpostor): number;
  61090. /**
  61091. * Gets the box size of the impostor
  61092. * @param impostor impostor to get box size from
  61093. * @param result the resulting box size
  61094. */
  61095. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61096. /**
  61097. * Disposes of the impostor
  61098. */
  61099. dispose(): void;
  61100. /**
  61101. * Does a raycast in the physics world
  61102. * @param from when should the ray start?
  61103. * @param to when should the ray end?
  61104. * @returns PhysicsRaycastResult
  61105. */
  61106. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61107. }
  61108. }
  61109. declare module BABYLON {
  61110. interface AbstractScene {
  61111. /**
  61112. * The list of reflection probes added to the scene
  61113. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61114. */
  61115. reflectionProbes: Array<ReflectionProbe>;
  61116. /**
  61117. * Removes the given reflection probe from this scene.
  61118. * @param toRemove The reflection probe to remove
  61119. * @returns The index of the removed reflection probe
  61120. */
  61121. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61122. /**
  61123. * Adds the given reflection probe to this scene.
  61124. * @param newReflectionProbe The reflection probe to add
  61125. */
  61126. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61127. }
  61128. /**
  61129. * Class used to generate realtime reflection / refraction cube textures
  61130. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61131. */
  61132. export class ReflectionProbe {
  61133. /** defines the name of the probe */
  61134. name: string;
  61135. private _scene;
  61136. private _renderTargetTexture;
  61137. private _projectionMatrix;
  61138. private _viewMatrix;
  61139. private _target;
  61140. private _add;
  61141. private _attachedMesh;
  61142. private _invertYAxis;
  61143. /** Gets or sets probe position (center of the cube map) */
  61144. position: Vector3;
  61145. /**
  61146. * Creates a new reflection probe
  61147. * @param name defines the name of the probe
  61148. * @param size defines the texture resolution (for each face)
  61149. * @param scene defines the hosting scene
  61150. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61151. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61152. */
  61153. constructor(
  61154. /** defines the name of the probe */
  61155. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61156. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61157. get samples(): number;
  61158. set samples(value: number);
  61159. /** Gets or sets the refresh rate to use (on every frame by default) */
  61160. get refreshRate(): number;
  61161. set refreshRate(value: number);
  61162. /**
  61163. * Gets the hosting scene
  61164. * @returns a Scene
  61165. */
  61166. getScene(): Scene;
  61167. /** Gets the internal CubeTexture used to render to */
  61168. get cubeTexture(): RenderTargetTexture;
  61169. /** Gets the list of meshes to render */
  61170. get renderList(): Nullable<AbstractMesh[]>;
  61171. /**
  61172. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61173. * @param mesh defines the mesh to attach to
  61174. */
  61175. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61176. /**
  61177. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61178. * @param renderingGroupId The rendering group id corresponding to its index
  61179. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61180. */
  61181. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61182. /**
  61183. * Clean all associated resources
  61184. */
  61185. dispose(): void;
  61186. /**
  61187. * Converts the reflection probe information to a readable string for debug purpose.
  61188. * @param fullDetails Supports for multiple levels of logging within scene loading
  61189. * @returns the human readable reflection probe info
  61190. */
  61191. toString(fullDetails?: boolean): string;
  61192. /**
  61193. * Get the class name of the relfection probe.
  61194. * @returns "ReflectionProbe"
  61195. */
  61196. getClassName(): string;
  61197. /**
  61198. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61199. * @returns The JSON representation of the texture
  61200. */
  61201. serialize(): any;
  61202. /**
  61203. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61204. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61205. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61206. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61207. * @returns The parsed reflection probe if successful
  61208. */
  61209. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61210. }
  61211. }
  61212. declare module BABYLON {
  61213. /** @hidden */
  61214. export var _BabylonLoaderRegistered: boolean;
  61215. /**
  61216. * Helps setting up some configuration for the babylon file loader.
  61217. */
  61218. export class BabylonFileLoaderConfiguration {
  61219. /**
  61220. * The loader does not allow injecting custom physix engine into the plugins.
  61221. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61222. * So you could set this variable to your engine import to make it work.
  61223. */
  61224. static LoaderInjectedPhysicsEngine: any;
  61225. }
  61226. }
  61227. declare module BABYLON {
  61228. /**
  61229. * The Physically based simple base material of BJS.
  61230. *
  61231. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61232. * It is used as the base class for both the specGloss and metalRough conventions.
  61233. */
  61234. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61235. /**
  61236. * Number of Simultaneous lights allowed on the material.
  61237. */
  61238. maxSimultaneousLights: number;
  61239. /**
  61240. * If sets to true, disables all the lights affecting the material.
  61241. */
  61242. disableLighting: boolean;
  61243. /**
  61244. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61245. */
  61246. environmentTexture: BaseTexture;
  61247. /**
  61248. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61249. */
  61250. invertNormalMapX: boolean;
  61251. /**
  61252. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61253. */
  61254. invertNormalMapY: boolean;
  61255. /**
  61256. * Normal map used in the model.
  61257. */
  61258. normalTexture: BaseTexture;
  61259. /**
  61260. * Emissivie color used to self-illuminate the model.
  61261. */
  61262. emissiveColor: Color3;
  61263. /**
  61264. * Emissivie texture used to self-illuminate the model.
  61265. */
  61266. emissiveTexture: BaseTexture;
  61267. /**
  61268. * Occlusion Channel Strenght.
  61269. */
  61270. occlusionStrength: number;
  61271. /**
  61272. * Occlusion Texture of the material (adding extra occlusion effects).
  61273. */
  61274. occlusionTexture: BaseTexture;
  61275. /**
  61276. * Defines the alpha limits in alpha test mode.
  61277. */
  61278. alphaCutOff: number;
  61279. /**
  61280. * Gets the current double sided mode.
  61281. */
  61282. get doubleSided(): boolean;
  61283. /**
  61284. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61285. */
  61286. set doubleSided(value: boolean);
  61287. /**
  61288. * Stores the pre-calculated light information of a mesh in a texture.
  61289. */
  61290. lightmapTexture: BaseTexture;
  61291. /**
  61292. * If true, the light map contains occlusion information instead of lighting info.
  61293. */
  61294. useLightmapAsShadowmap: boolean;
  61295. /**
  61296. * Instantiates a new PBRMaterial instance.
  61297. *
  61298. * @param name The material name
  61299. * @param scene The scene the material will be use in.
  61300. */
  61301. constructor(name: string, scene: Scene);
  61302. getClassName(): string;
  61303. }
  61304. }
  61305. declare module BABYLON {
  61306. /**
  61307. * The PBR material of BJS following the metal roughness convention.
  61308. *
  61309. * This fits to the PBR convention in the GLTF definition:
  61310. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61311. */
  61312. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61313. /**
  61314. * The base color has two different interpretations depending on the value of metalness.
  61315. * When the material is a metal, the base color is the specific measured reflectance value
  61316. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61317. * of the material.
  61318. */
  61319. baseColor: Color3;
  61320. /**
  61321. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61322. * well as opacity information in the alpha channel.
  61323. */
  61324. baseTexture: BaseTexture;
  61325. /**
  61326. * Specifies the metallic scalar value of the material.
  61327. * Can also be used to scale the metalness values of the metallic texture.
  61328. */
  61329. metallic: number;
  61330. /**
  61331. * Specifies the roughness scalar value of the material.
  61332. * Can also be used to scale the roughness values of the metallic texture.
  61333. */
  61334. roughness: number;
  61335. /**
  61336. * Texture containing both the metallic value in the B channel and the
  61337. * roughness value in the G channel to keep better precision.
  61338. */
  61339. metallicRoughnessTexture: BaseTexture;
  61340. /**
  61341. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61342. *
  61343. * @param name The material name
  61344. * @param scene The scene the material will be use in.
  61345. */
  61346. constructor(name: string, scene: Scene);
  61347. /**
  61348. * Return the currrent class name of the material.
  61349. */
  61350. getClassName(): string;
  61351. /**
  61352. * Makes a duplicate of the current material.
  61353. * @param name - name to use for the new material.
  61354. */
  61355. clone(name: string): PBRMetallicRoughnessMaterial;
  61356. /**
  61357. * Serialize the material to a parsable JSON object.
  61358. */
  61359. serialize(): any;
  61360. /**
  61361. * Parses a JSON object correponding to the serialize function.
  61362. */
  61363. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61364. }
  61365. }
  61366. declare module BABYLON {
  61367. /**
  61368. * The PBR material of BJS following the specular glossiness convention.
  61369. *
  61370. * This fits to the PBR convention in the GLTF definition:
  61371. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61372. */
  61373. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61374. /**
  61375. * Specifies the diffuse color of the material.
  61376. */
  61377. diffuseColor: Color3;
  61378. /**
  61379. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61380. * channel.
  61381. */
  61382. diffuseTexture: BaseTexture;
  61383. /**
  61384. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61385. */
  61386. specularColor: Color3;
  61387. /**
  61388. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61389. */
  61390. glossiness: number;
  61391. /**
  61392. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61393. */
  61394. specularGlossinessTexture: BaseTexture;
  61395. /**
  61396. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61397. *
  61398. * @param name The material name
  61399. * @param scene The scene the material will be use in.
  61400. */
  61401. constructor(name: string, scene: Scene);
  61402. /**
  61403. * Return the currrent class name of the material.
  61404. */
  61405. getClassName(): string;
  61406. /**
  61407. * Makes a duplicate of the current material.
  61408. * @param name - name to use for the new material.
  61409. */
  61410. clone(name: string): PBRSpecularGlossinessMaterial;
  61411. /**
  61412. * Serialize the material to a parsable JSON object.
  61413. */
  61414. serialize(): any;
  61415. /**
  61416. * Parses a JSON object correponding to the serialize function.
  61417. */
  61418. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61419. }
  61420. }
  61421. declare module BABYLON {
  61422. /**
  61423. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61424. * It can help converting any input color in a desired output one. This can then be used to create effects
  61425. * from sepia, black and white to sixties or futuristic rendering...
  61426. *
  61427. * The only supported format is currently 3dl.
  61428. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61429. */
  61430. export class ColorGradingTexture extends BaseTexture {
  61431. /**
  61432. * The texture URL.
  61433. */
  61434. url: string;
  61435. /**
  61436. * Empty line regex stored for GC.
  61437. */
  61438. private static _noneEmptyLineRegex;
  61439. private _textureMatrix;
  61440. private _onLoad;
  61441. /**
  61442. * Instantiates a ColorGradingTexture from the following parameters.
  61443. *
  61444. * @param url The location of the color gradind data (currently only supporting 3dl)
  61445. * @param sceneOrEngine The scene or engine the texture will be used in
  61446. * @param onLoad defines a callback triggered when the texture has been loaded
  61447. */
  61448. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61449. /**
  61450. * Fires the onload event from the constructor if requested.
  61451. */
  61452. private _triggerOnLoad;
  61453. /**
  61454. * Returns the texture matrix used in most of the material.
  61455. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61456. */
  61457. getTextureMatrix(): Matrix;
  61458. /**
  61459. * Occurs when the file being loaded is a .3dl LUT file.
  61460. */
  61461. private load3dlTexture;
  61462. /**
  61463. * Starts the loading process of the texture.
  61464. */
  61465. private loadTexture;
  61466. /**
  61467. * Clones the color gradind texture.
  61468. */
  61469. clone(): ColorGradingTexture;
  61470. /**
  61471. * Called during delayed load for textures.
  61472. */
  61473. delayLoad(): void;
  61474. /**
  61475. * Parses a color grading texture serialized by Babylon.
  61476. * @param parsedTexture The texture information being parsedTexture
  61477. * @param scene The scene to load the texture in
  61478. * @param rootUrl The root url of the data assets to load
  61479. * @return A color gradind texture
  61480. */
  61481. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61482. /**
  61483. * Serializes the LUT texture to json format.
  61484. */
  61485. serialize(): any;
  61486. }
  61487. }
  61488. declare module BABYLON {
  61489. /**
  61490. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61491. */
  61492. export class EquiRectangularCubeTexture extends BaseTexture {
  61493. /** The six faces of the cube. */
  61494. private static _FacesMapping;
  61495. private _noMipmap;
  61496. private _onLoad;
  61497. private _onError;
  61498. /** The size of the cubemap. */
  61499. private _size;
  61500. /** The buffer of the image. */
  61501. private _buffer;
  61502. /** The width of the input image. */
  61503. private _width;
  61504. /** The height of the input image. */
  61505. private _height;
  61506. /** The URL to the image. */
  61507. url: string;
  61508. /**
  61509. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61510. * @param url The location of the image
  61511. * @param scene The scene the texture will be used in
  61512. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61513. * @param noMipmap Forces to not generate the mipmap if true
  61514. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61515. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61516. * @param onLoad — defines a callback called when texture is loaded
  61517. * @param onError — defines a callback called if there is an error
  61518. */
  61519. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61520. /**
  61521. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61522. */
  61523. private loadImage;
  61524. /**
  61525. * Convert the image buffer into a cubemap and create a CubeTexture.
  61526. */
  61527. private loadTexture;
  61528. /**
  61529. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61530. * @param buffer The ArrayBuffer that should be converted.
  61531. * @returns The buffer as Float32Array.
  61532. */
  61533. private getFloat32ArrayFromArrayBuffer;
  61534. /**
  61535. * Get the current class name of the texture useful for serialization or dynamic coding.
  61536. * @returns "EquiRectangularCubeTexture"
  61537. */
  61538. getClassName(): string;
  61539. /**
  61540. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61541. * @returns A clone of the current EquiRectangularCubeTexture.
  61542. */
  61543. clone(): EquiRectangularCubeTexture;
  61544. }
  61545. }
  61546. declare module BABYLON {
  61547. /**
  61548. * Defines the options related to the creation of an HtmlElementTexture
  61549. */
  61550. export interface IHtmlElementTextureOptions {
  61551. /**
  61552. * Defines wether mip maps should be created or not.
  61553. */
  61554. generateMipMaps?: boolean;
  61555. /**
  61556. * Defines the sampling mode of the texture.
  61557. */
  61558. samplingMode?: number;
  61559. /**
  61560. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61561. */
  61562. engine: Nullable<ThinEngine>;
  61563. /**
  61564. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61565. */
  61566. scene: Nullable<Scene>;
  61567. }
  61568. /**
  61569. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61570. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61571. * is automatically managed.
  61572. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61573. * in your application.
  61574. *
  61575. * As the update is not automatic, you need to call them manually.
  61576. */
  61577. export class HtmlElementTexture extends BaseTexture {
  61578. /**
  61579. * The texture URL.
  61580. */
  61581. element: HTMLVideoElement | HTMLCanvasElement;
  61582. private static readonly DefaultOptions;
  61583. private _textureMatrix;
  61584. private _isVideo;
  61585. private _generateMipMaps;
  61586. private _samplingMode;
  61587. /**
  61588. * Instantiates a HtmlElementTexture from the following parameters.
  61589. *
  61590. * @param name Defines the name of the texture
  61591. * @param element Defines the video or canvas the texture is filled with
  61592. * @param options Defines the other none mandatory texture creation options
  61593. */
  61594. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61595. private _createInternalTexture;
  61596. /**
  61597. * Returns the texture matrix used in most of the material.
  61598. */
  61599. getTextureMatrix(): Matrix;
  61600. /**
  61601. * Updates the content of the texture.
  61602. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61603. */
  61604. update(invertY?: Nullable<boolean>): void;
  61605. }
  61606. }
  61607. declare module BABYLON {
  61608. /**
  61609. * Based on jsTGALoader - Javascript loader for TGA file
  61610. * By Vincent Thibault
  61611. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61612. */
  61613. export class TGATools {
  61614. private static _TYPE_INDEXED;
  61615. private static _TYPE_RGB;
  61616. private static _TYPE_GREY;
  61617. private static _TYPE_RLE_INDEXED;
  61618. private static _TYPE_RLE_RGB;
  61619. private static _TYPE_RLE_GREY;
  61620. private static _ORIGIN_MASK;
  61621. private static _ORIGIN_SHIFT;
  61622. private static _ORIGIN_BL;
  61623. private static _ORIGIN_BR;
  61624. private static _ORIGIN_UL;
  61625. private static _ORIGIN_UR;
  61626. /**
  61627. * Gets the header of a TGA file
  61628. * @param data defines the TGA data
  61629. * @returns the header
  61630. */
  61631. static GetTGAHeader(data: Uint8Array): any;
  61632. /**
  61633. * Uploads TGA content to a Babylon Texture
  61634. * @hidden
  61635. */
  61636. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61637. /** @hidden */
  61638. 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;
  61639. /** @hidden */
  61640. 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;
  61641. /** @hidden */
  61642. 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;
  61643. /** @hidden */
  61644. 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;
  61645. /** @hidden */
  61646. 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;
  61647. /** @hidden */
  61648. 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;
  61649. }
  61650. }
  61651. declare module BABYLON {
  61652. /**
  61653. * Implementation of the TGA Texture Loader.
  61654. * @hidden
  61655. */
  61656. export class _TGATextureLoader implements IInternalTextureLoader {
  61657. /**
  61658. * Defines wether the loader supports cascade loading the different faces.
  61659. */
  61660. readonly supportCascades: boolean;
  61661. /**
  61662. * This returns if the loader support the current file information.
  61663. * @param extension defines the file extension of the file being loaded
  61664. * @returns true if the loader can load the specified file
  61665. */
  61666. canLoad(extension: string): boolean;
  61667. /**
  61668. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61669. * @param data contains the texture data
  61670. * @param texture defines the BabylonJS internal texture
  61671. * @param createPolynomials will be true if polynomials have been requested
  61672. * @param onLoad defines the callback to trigger once the texture is ready
  61673. * @param onError defines the callback to trigger in case of error
  61674. */
  61675. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61676. /**
  61677. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61678. * @param data contains the texture data
  61679. * @param texture defines the BabylonJS internal texture
  61680. * @param callback defines the method to call once ready to upload
  61681. */
  61682. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61683. }
  61684. }
  61685. declare module BABYLON {
  61686. /**
  61687. * Info about the .basis files
  61688. */
  61689. class BasisFileInfo {
  61690. /**
  61691. * If the file has alpha
  61692. */
  61693. hasAlpha: boolean;
  61694. /**
  61695. * Info about each image of the basis file
  61696. */
  61697. images: Array<{
  61698. levels: Array<{
  61699. width: number;
  61700. height: number;
  61701. transcodedPixels: ArrayBufferView;
  61702. }>;
  61703. }>;
  61704. }
  61705. /**
  61706. * Result of transcoding a basis file
  61707. */
  61708. class TranscodeResult {
  61709. /**
  61710. * Info about the .basis file
  61711. */
  61712. fileInfo: BasisFileInfo;
  61713. /**
  61714. * Format to use when loading the file
  61715. */
  61716. format: number;
  61717. }
  61718. /**
  61719. * Configuration options for the Basis transcoder
  61720. */
  61721. export class BasisTranscodeConfiguration {
  61722. /**
  61723. * Supported compression formats used to determine the supported output format of the transcoder
  61724. */
  61725. supportedCompressionFormats?: {
  61726. /**
  61727. * etc1 compression format
  61728. */
  61729. etc1?: boolean;
  61730. /**
  61731. * s3tc compression format
  61732. */
  61733. s3tc?: boolean;
  61734. /**
  61735. * pvrtc compression format
  61736. */
  61737. pvrtc?: boolean;
  61738. /**
  61739. * etc2 compression format
  61740. */
  61741. etc2?: boolean;
  61742. };
  61743. /**
  61744. * If mipmap levels should be loaded for transcoded images (Default: true)
  61745. */
  61746. loadMipmapLevels?: boolean;
  61747. /**
  61748. * Index of a single image to load (Default: all images)
  61749. */
  61750. loadSingleImage?: number;
  61751. }
  61752. /**
  61753. * Used to load .Basis files
  61754. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61755. */
  61756. export class BasisTools {
  61757. private static _IgnoreSupportedFormats;
  61758. /**
  61759. * URL to use when loading the basis transcoder
  61760. */
  61761. static JSModuleURL: string;
  61762. /**
  61763. * URL to use when loading the wasm module for the transcoder
  61764. */
  61765. static WasmModuleURL: string;
  61766. /**
  61767. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61768. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61769. * @returns internal format corresponding to the Basis format
  61770. */
  61771. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61772. private static _WorkerPromise;
  61773. private static _Worker;
  61774. private static _actionId;
  61775. private static _CreateWorkerAsync;
  61776. /**
  61777. * Transcodes a loaded image file to compressed pixel data
  61778. * @param data image data to transcode
  61779. * @param config configuration options for the transcoding
  61780. * @returns a promise resulting in the transcoded image
  61781. */
  61782. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61783. /**
  61784. * Loads a texture from the transcode result
  61785. * @param texture texture load to
  61786. * @param transcodeResult the result of transcoding the basis file to load from
  61787. */
  61788. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61789. }
  61790. }
  61791. declare module BABYLON {
  61792. /**
  61793. * Loader for .basis file format
  61794. */
  61795. export class _BasisTextureLoader implements IInternalTextureLoader {
  61796. /**
  61797. * Defines whether the loader supports cascade loading the different faces.
  61798. */
  61799. readonly supportCascades: boolean;
  61800. /**
  61801. * This returns if the loader support the current file information.
  61802. * @param extension defines the file extension of the file being loaded
  61803. * @returns true if the loader can load the specified file
  61804. */
  61805. canLoad(extension: string): boolean;
  61806. /**
  61807. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61808. * @param data contains the texture data
  61809. * @param texture defines the BabylonJS internal texture
  61810. * @param createPolynomials will be true if polynomials have been requested
  61811. * @param onLoad defines the callback to trigger once the texture is ready
  61812. * @param onError defines the callback to trigger in case of error
  61813. */
  61814. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61815. /**
  61816. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61817. * @param data contains the texture data
  61818. * @param texture defines the BabylonJS internal texture
  61819. * @param callback defines the method to call once ready to upload
  61820. */
  61821. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * Defines the basic options interface of a TexturePacker Frame
  61827. */
  61828. export interface ITexturePackerFrame {
  61829. /**
  61830. * The frame ID
  61831. */
  61832. id: number;
  61833. /**
  61834. * The frames Scale
  61835. */
  61836. scale: Vector2;
  61837. /**
  61838. * The Frames offset
  61839. */
  61840. offset: Vector2;
  61841. }
  61842. /**
  61843. * This is a support class for frame Data on texture packer sets.
  61844. */
  61845. export class TexturePackerFrame implements ITexturePackerFrame {
  61846. /**
  61847. * The frame ID
  61848. */
  61849. id: number;
  61850. /**
  61851. * The frames Scale
  61852. */
  61853. scale: Vector2;
  61854. /**
  61855. * The Frames offset
  61856. */
  61857. offset: Vector2;
  61858. /**
  61859. * Initializes a texture package frame.
  61860. * @param id The numerical frame identifier
  61861. * @param scale Scalar Vector2 for UV frame
  61862. * @param offset Vector2 for the frame position in UV units.
  61863. * @returns TexturePackerFrame
  61864. */
  61865. constructor(id: number, scale: Vector2, offset: Vector2);
  61866. }
  61867. }
  61868. declare module BABYLON {
  61869. /**
  61870. * Defines the basic options interface of a TexturePacker
  61871. */
  61872. export interface ITexturePackerOptions {
  61873. /**
  61874. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61875. */
  61876. map?: string[];
  61877. /**
  61878. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61879. */
  61880. uvsIn?: string;
  61881. /**
  61882. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61883. */
  61884. uvsOut?: string;
  61885. /**
  61886. * number representing the layout style. Defaults to LAYOUT_STRIP
  61887. */
  61888. layout?: number;
  61889. /**
  61890. * number of columns if using custom column count layout(2). This defaults to 4.
  61891. */
  61892. colnum?: number;
  61893. /**
  61894. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61895. */
  61896. updateInputMeshes?: boolean;
  61897. /**
  61898. * boolean flag to dispose all the source textures. Defaults to true.
  61899. */
  61900. disposeSources?: boolean;
  61901. /**
  61902. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61903. */
  61904. fillBlanks?: boolean;
  61905. /**
  61906. * string value representing the context fill style color. Defaults to 'black'.
  61907. */
  61908. customFillColor?: string;
  61909. /**
  61910. * Width and Height Value of each Frame in the TexturePacker Sets
  61911. */
  61912. frameSize?: number;
  61913. /**
  61914. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61915. */
  61916. paddingRatio?: number;
  61917. /**
  61918. * Number that declares the fill method for the padding gutter.
  61919. */
  61920. paddingMode?: number;
  61921. /**
  61922. * If in SUBUV_COLOR padding mode what color to use.
  61923. */
  61924. paddingColor?: Color3 | Color4;
  61925. }
  61926. /**
  61927. * Defines the basic interface of a TexturePacker JSON File
  61928. */
  61929. export interface ITexturePackerJSON {
  61930. /**
  61931. * The frame ID
  61932. */
  61933. name: string;
  61934. /**
  61935. * The base64 channel data
  61936. */
  61937. sets: any;
  61938. /**
  61939. * The options of the Packer
  61940. */
  61941. options: ITexturePackerOptions;
  61942. /**
  61943. * The frame data of the Packer
  61944. */
  61945. frames: Array<number>;
  61946. }
  61947. /**
  61948. * This is a support class that generates a series of packed texture sets.
  61949. * @see https://doc.babylonjs.com/babylon101/materials
  61950. */
  61951. export class TexturePacker {
  61952. /** Packer Layout Constant 0 */
  61953. static readonly LAYOUT_STRIP: number;
  61954. /** Packer Layout Constant 1 */
  61955. static readonly LAYOUT_POWER2: number;
  61956. /** Packer Layout Constant 2 */
  61957. static readonly LAYOUT_COLNUM: number;
  61958. /** Packer Layout Constant 0 */
  61959. static readonly SUBUV_WRAP: number;
  61960. /** Packer Layout Constant 1 */
  61961. static readonly SUBUV_EXTEND: number;
  61962. /** Packer Layout Constant 2 */
  61963. static readonly SUBUV_COLOR: number;
  61964. /** The Name of the Texture Package */
  61965. name: string;
  61966. /** The scene scope of the TexturePacker */
  61967. scene: Scene;
  61968. /** The Meshes to target */
  61969. meshes: AbstractMesh[];
  61970. /** Arguments passed with the Constructor */
  61971. options: ITexturePackerOptions;
  61972. /** The promise that is started upon initialization */
  61973. promise: Nullable<Promise<TexturePacker | string>>;
  61974. /** The Container object for the channel sets that are generated */
  61975. sets: object;
  61976. /** The Container array for the frames that are generated */
  61977. frames: TexturePackerFrame[];
  61978. /** The expected number of textures the system is parsing. */
  61979. private _expecting;
  61980. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61981. private _paddingValue;
  61982. /**
  61983. * Initializes a texture package series from an array of meshes or a single mesh.
  61984. * @param name The name of the package
  61985. * @param meshes The target meshes to compose the package from
  61986. * @param options The arguments that texture packer should follow while building.
  61987. * @param scene The scene which the textures are scoped to.
  61988. * @returns TexturePacker
  61989. */
  61990. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61991. /**
  61992. * Starts the package process
  61993. * @param resolve The promises resolution function
  61994. * @returns TexturePacker
  61995. */
  61996. private _createFrames;
  61997. /**
  61998. * Calculates the Size of the Channel Sets
  61999. * @returns Vector2
  62000. */
  62001. private _calculateSize;
  62002. /**
  62003. * Calculates the UV data for the frames.
  62004. * @param baseSize the base frameSize
  62005. * @param padding the base frame padding
  62006. * @param dtSize size of the Dynamic Texture for that channel
  62007. * @param dtUnits is 1/dtSize
  62008. * @param update flag to update the input meshes
  62009. */
  62010. private _calculateMeshUVFrames;
  62011. /**
  62012. * Calculates the frames Offset.
  62013. * @param index of the frame
  62014. * @returns Vector2
  62015. */
  62016. private _getFrameOffset;
  62017. /**
  62018. * Updates a Mesh to the frame data
  62019. * @param mesh that is the target
  62020. * @param frameID or the frame index
  62021. */
  62022. private _updateMeshUV;
  62023. /**
  62024. * Updates a Meshes materials to use the texture packer channels
  62025. * @param m is the mesh to target
  62026. * @param force all channels on the packer to be set.
  62027. */
  62028. private _updateTextureReferences;
  62029. /**
  62030. * Public method to set a Mesh to a frame
  62031. * @param m that is the target
  62032. * @param frameID or the frame index
  62033. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62034. */
  62035. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62036. /**
  62037. * Starts the async promise to compile the texture packer.
  62038. * @returns Promise<void>
  62039. */
  62040. processAsync(): Promise<void>;
  62041. /**
  62042. * Disposes all textures associated with this packer
  62043. */
  62044. dispose(): void;
  62045. /**
  62046. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62047. * @param imageType is the image type to use.
  62048. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62049. */
  62050. download(imageType?: string, quality?: number): void;
  62051. /**
  62052. * Public method to load a texturePacker JSON file.
  62053. * @param data of the JSON file in string format.
  62054. */
  62055. updateFromJSON(data: string): void;
  62056. }
  62057. }
  62058. declare module BABYLON {
  62059. /**
  62060. * 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.
  62061. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62062. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62063. */
  62064. export class CustomProceduralTexture extends ProceduralTexture {
  62065. private _animate;
  62066. private _time;
  62067. private _config;
  62068. private _texturePath;
  62069. /**
  62070. * Instantiates a new Custom Procedural Texture.
  62071. * 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.
  62072. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62073. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62074. * @param name Define the name of the texture
  62075. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62076. * @param size Define the size of the texture to create
  62077. * @param scene Define the scene the texture belongs to
  62078. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62079. * @param generateMipMaps Define if the texture should creates mip maps or not
  62080. */
  62081. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62082. private _loadJson;
  62083. /**
  62084. * Is the texture ready to be used ? (rendered at least once)
  62085. * @returns true if ready, otherwise, false.
  62086. */
  62087. isReady(): boolean;
  62088. /**
  62089. * Render the texture to its associated render target.
  62090. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62091. */
  62092. render(useCameraPostProcess?: boolean): void;
  62093. /**
  62094. * Update the list of dependant textures samplers in the shader.
  62095. */
  62096. updateTextures(): void;
  62097. /**
  62098. * Update the uniform values of the procedural texture in the shader.
  62099. */
  62100. updateShaderUniforms(): void;
  62101. /**
  62102. * Define if the texture animates or not.
  62103. */
  62104. get animate(): boolean;
  62105. set animate(value: boolean);
  62106. }
  62107. }
  62108. declare module BABYLON {
  62109. /** @hidden */
  62110. export var noisePixelShader: {
  62111. name: string;
  62112. shader: string;
  62113. };
  62114. }
  62115. declare module BABYLON {
  62116. /**
  62117. * Class used to generate noise procedural textures
  62118. */
  62119. export class NoiseProceduralTexture extends ProceduralTexture {
  62120. /** Gets or sets the start time (default is 0) */
  62121. time: number;
  62122. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62123. brightness: number;
  62124. /** Defines the number of octaves to process */
  62125. octaves: number;
  62126. /** Defines the level of persistence (0.8 by default) */
  62127. persistence: number;
  62128. /** Gets or sets animation speed factor (default is 1) */
  62129. animationSpeedFactor: number;
  62130. /**
  62131. * Creates a new NoiseProceduralTexture
  62132. * @param name defines the name fo the texture
  62133. * @param size defines the size of the texture (default is 256)
  62134. * @param scene defines the hosting scene
  62135. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62136. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62137. */
  62138. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62139. private _updateShaderUniforms;
  62140. protected _getDefines(): string;
  62141. /** Generate the current state of the procedural texture */
  62142. render(useCameraPostProcess?: boolean): void;
  62143. /**
  62144. * Serializes this noise procedural texture
  62145. * @returns a serialized noise procedural texture object
  62146. */
  62147. serialize(): any;
  62148. /**
  62149. * Clone the texture.
  62150. * @returns the cloned texture
  62151. */
  62152. clone(): NoiseProceduralTexture;
  62153. /**
  62154. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62155. * @param parsedTexture defines parsed texture data
  62156. * @param scene defines the current scene
  62157. * @param rootUrl defines the root URL containing noise procedural texture information
  62158. * @returns a parsed NoiseProceduralTexture
  62159. */
  62160. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62161. }
  62162. }
  62163. declare module BABYLON {
  62164. /**
  62165. * Raw cube texture where the raw buffers are passed in
  62166. */
  62167. export class RawCubeTexture extends CubeTexture {
  62168. /**
  62169. * Creates a cube texture where the raw buffers are passed in.
  62170. * @param scene defines the scene the texture is attached to
  62171. * @param data defines the array of data to use to create each face
  62172. * @param size defines the size of the textures
  62173. * @param format defines the format of the data
  62174. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62175. * @param generateMipMaps defines if the engine should generate the mip levels
  62176. * @param invertY defines if data must be stored with Y axis inverted
  62177. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62178. * @param compression defines the compression used (null by default)
  62179. */
  62180. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62181. /**
  62182. * Updates the raw cube texture.
  62183. * @param data defines the data to store
  62184. * @param format defines the data format
  62185. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62186. * @param invertY defines if data must be stored with Y axis inverted
  62187. * @param compression defines the compression used (null by default)
  62188. * @param level defines which level of the texture to update
  62189. */
  62190. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62191. /**
  62192. * Updates a raw cube texture with RGBD encoded data.
  62193. * @param data defines the array of data [mipmap][face] to use to create each face
  62194. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62195. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62196. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62197. * @returns a promsie that resolves when the operation is complete
  62198. */
  62199. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62200. /**
  62201. * Clones the raw cube texture.
  62202. * @return a new cube texture
  62203. */
  62204. clone(): CubeTexture;
  62205. /** @hidden */
  62206. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62207. }
  62208. }
  62209. declare module BABYLON {
  62210. /**
  62211. * Class used to store 2D array textures containing user data
  62212. */
  62213. export class RawTexture2DArray extends Texture {
  62214. /** Gets or sets the texture format to use */
  62215. format: number;
  62216. /**
  62217. * Create a new RawTexture2DArray
  62218. * @param data defines the data of the texture
  62219. * @param width defines the width of the texture
  62220. * @param height defines the height of the texture
  62221. * @param depth defines the number of layers of the texture
  62222. * @param format defines the texture format to use
  62223. * @param scene defines the hosting scene
  62224. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62225. * @param invertY defines if texture must be stored with Y axis inverted
  62226. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62227. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62228. */
  62229. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62230. /** Gets or sets the texture format to use */
  62231. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62232. /**
  62233. * Update the texture with new data
  62234. * @param data defines the data to store in the texture
  62235. */
  62236. update(data: ArrayBufferView): void;
  62237. }
  62238. }
  62239. declare module BABYLON {
  62240. /**
  62241. * Class used to store 3D textures containing user data
  62242. */
  62243. export class RawTexture3D extends Texture {
  62244. /** Gets or sets the texture format to use */
  62245. format: number;
  62246. /**
  62247. * Create a new RawTexture3D
  62248. * @param data defines the data of the texture
  62249. * @param width defines the width of the texture
  62250. * @param height defines the height of the texture
  62251. * @param depth defines the depth of the texture
  62252. * @param format defines the texture format to use
  62253. * @param scene defines the hosting scene
  62254. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62255. * @param invertY defines if texture must be stored with Y axis inverted
  62256. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62257. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62258. */
  62259. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62260. /** Gets or sets the texture format to use */
  62261. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62262. /**
  62263. * Update the texture with new data
  62264. * @param data defines the data to store in the texture
  62265. */
  62266. update(data: ArrayBufferView): void;
  62267. }
  62268. }
  62269. declare module BABYLON {
  62270. /**
  62271. * Creates a refraction texture used by refraction channel of the standard material.
  62272. * It is like a mirror but to see through a material.
  62273. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62274. */
  62275. export class RefractionTexture extends RenderTargetTexture {
  62276. /**
  62277. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62278. * 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.
  62279. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62280. */
  62281. refractionPlane: Plane;
  62282. /**
  62283. * Define how deep under the surface we should see.
  62284. */
  62285. depth: number;
  62286. /**
  62287. * Creates a refraction texture used by refraction channel of the standard material.
  62288. * It is like a mirror but to see through a material.
  62289. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62290. * @param name Define the texture name
  62291. * @param size Define the size of the underlying texture
  62292. * @param scene Define the scene the refraction belongs to
  62293. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62294. */
  62295. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62296. /**
  62297. * Clone the refraction texture.
  62298. * @returns the cloned texture
  62299. */
  62300. clone(): RefractionTexture;
  62301. /**
  62302. * Serialize the texture to a JSON representation you could use in Parse later on
  62303. * @returns the serialized JSON representation
  62304. */
  62305. serialize(): any;
  62306. }
  62307. }
  62308. declare module BABYLON {
  62309. /**
  62310. * Block used to add support for vertex skinning (bones)
  62311. */
  62312. export class BonesBlock extends NodeMaterialBlock {
  62313. /**
  62314. * Creates a new BonesBlock
  62315. * @param name defines the block name
  62316. */
  62317. constructor(name: string);
  62318. /**
  62319. * Initialize the block and prepare the context for build
  62320. * @param state defines the state that will be used for the build
  62321. */
  62322. initialize(state: NodeMaterialBuildState): void;
  62323. /**
  62324. * Gets the current class name
  62325. * @returns the class name
  62326. */
  62327. getClassName(): string;
  62328. /**
  62329. * Gets the matrix indices input component
  62330. */
  62331. get matricesIndices(): NodeMaterialConnectionPoint;
  62332. /**
  62333. * Gets the matrix weights input component
  62334. */
  62335. get matricesWeights(): NodeMaterialConnectionPoint;
  62336. /**
  62337. * Gets the extra matrix indices input component
  62338. */
  62339. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62340. /**
  62341. * Gets the extra matrix weights input component
  62342. */
  62343. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62344. /**
  62345. * Gets the world input component
  62346. */
  62347. get world(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the output component
  62350. */
  62351. get output(): NodeMaterialConnectionPoint;
  62352. autoConfigure(material: NodeMaterial): void;
  62353. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62356. protected _buildBlock(state: NodeMaterialBuildState): this;
  62357. }
  62358. }
  62359. declare module BABYLON {
  62360. /**
  62361. * Block used to add support for instances
  62362. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62363. */
  62364. export class InstancesBlock extends NodeMaterialBlock {
  62365. /**
  62366. * Creates a new InstancesBlock
  62367. * @param name defines the block name
  62368. */
  62369. constructor(name: string);
  62370. /**
  62371. * Gets the current class name
  62372. * @returns the class name
  62373. */
  62374. getClassName(): string;
  62375. /**
  62376. * Gets the first world row input component
  62377. */
  62378. get world0(): NodeMaterialConnectionPoint;
  62379. /**
  62380. * Gets the second world row input component
  62381. */
  62382. get world1(): NodeMaterialConnectionPoint;
  62383. /**
  62384. * Gets the third world row input component
  62385. */
  62386. get world2(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the forth world row input component
  62389. */
  62390. get world3(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the world input component
  62393. */
  62394. get world(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the output component
  62397. */
  62398. get output(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the isntanceID component
  62401. */
  62402. get instanceID(): NodeMaterialConnectionPoint;
  62403. autoConfigure(material: NodeMaterial): void;
  62404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62405. protected _buildBlock(state: NodeMaterialBuildState): this;
  62406. }
  62407. }
  62408. declare module BABYLON {
  62409. /**
  62410. * Block used to add morph targets support to vertex shader
  62411. */
  62412. export class MorphTargetsBlock extends NodeMaterialBlock {
  62413. private _repeatableContentAnchor;
  62414. /**
  62415. * Create a new MorphTargetsBlock
  62416. * @param name defines the block name
  62417. */
  62418. constructor(name: string);
  62419. /**
  62420. * Gets the current class name
  62421. * @returns the class name
  62422. */
  62423. getClassName(): string;
  62424. /**
  62425. * Gets the position input component
  62426. */
  62427. get position(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the normal input component
  62430. */
  62431. get normal(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the tangent input component
  62434. */
  62435. get tangent(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the tangent input component
  62438. */
  62439. get uv(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the position output component
  62442. */
  62443. get positionOutput(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the normal output component
  62446. */
  62447. get normalOutput(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the tangent output component
  62450. */
  62451. get tangentOutput(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the tangent output component
  62454. */
  62455. get uvOutput(): NodeMaterialConnectionPoint;
  62456. initialize(state: NodeMaterialBuildState): void;
  62457. autoConfigure(material: NodeMaterial): void;
  62458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62459. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62460. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62461. protected _buildBlock(state: NodeMaterialBuildState): this;
  62462. }
  62463. }
  62464. declare module BABYLON {
  62465. /**
  62466. * Block used to get data information from a light
  62467. */
  62468. export class LightInformationBlock extends NodeMaterialBlock {
  62469. private _lightDataUniformName;
  62470. private _lightColorUniformName;
  62471. private _lightTypeDefineName;
  62472. /**
  62473. * Gets or sets the light associated with this block
  62474. */
  62475. light: Nullable<Light>;
  62476. /**
  62477. * Creates a new LightInformationBlock
  62478. * @param name defines the block name
  62479. */
  62480. constructor(name: string);
  62481. /**
  62482. * Gets the current class name
  62483. * @returns the class name
  62484. */
  62485. getClassName(): string;
  62486. /**
  62487. * Gets the world position input component
  62488. */
  62489. get worldPosition(): NodeMaterialConnectionPoint;
  62490. /**
  62491. * Gets the direction output component
  62492. */
  62493. get direction(): NodeMaterialConnectionPoint;
  62494. /**
  62495. * Gets the direction output component
  62496. */
  62497. get color(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the direction output component
  62500. */
  62501. get intensity(): NodeMaterialConnectionPoint;
  62502. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62503. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62504. protected _buildBlock(state: NodeMaterialBuildState): this;
  62505. serialize(): any;
  62506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62507. }
  62508. }
  62509. declare module BABYLON {
  62510. /**
  62511. * Block used to add image processing support to fragment shader
  62512. */
  62513. export class ImageProcessingBlock extends NodeMaterialBlock {
  62514. /**
  62515. * Create a new ImageProcessingBlock
  62516. * @param name defines the block name
  62517. */
  62518. constructor(name: string);
  62519. /**
  62520. * Gets the current class name
  62521. * @returns the class name
  62522. */
  62523. getClassName(): string;
  62524. /**
  62525. * Gets the color input component
  62526. */
  62527. get color(): NodeMaterialConnectionPoint;
  62528. /**
  62529. * Gets the output component
  62530. */
  62531. get output(): NodeMaterialConnectionPoint;
  62532. /**
  62533. * Initialize the block and prepare the context for build
  62534. * @param state defines the state that will be used for the build
  62535. */
  62536. initialize(state: NodeMaterialBuildState): void;
  62537. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62540. protected _buildBlock(state: NodeMaterialBuildState): this;
  62541. }
  62542. }
  62543. declare module BABYLON {
  62544. /**
  62545. * Block used to pertub normals based on a normal map
  62546. */
  62547. export class PerturbNormalBlock extends NodeMaterialBlock {
  62548. private _tangentSpaceParameterName;
  62549. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62550. invertX: boolean;
  62551. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62552. invertY: boolean;
  62553. /**
  62554. * Create a new PerturbNormalBlock
  62555. * @param name defines the block name
  62556. */
  62557. constructor(name: string);
  62558. /**
  62559. * Gets the current class name
  62560. * @returns the class name
  62561. */
  62562. getClassName(): string;
  62563. /**
  62564. * Gets the world position input component
  62565. */
  62566. get worldPosition(): NodeMaterialConnectionPoint;
  62567. /**
  62568. * Gets the world normal input component
  62569. */
  62570. get worldNormal(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the world tangent input component
  62573. */
  62574. get worldTangent(): NodeMaterialConnectionPoint;
  62575. /**
  62576. * Gets the uv input component
  62577. */
  62578. get uv(): NodeMaterialConnectionPoint;
  62579. /**
  62580. * Gets the normal map color input component
  62581. */
  62582. get normalMapColor(): NodeMaterialConnectionPoint;
  62583. /**
  62584. * Gets the strength input component
  62585. */
  62586. get strength(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the output component
  62589. */
  62590. get output(): NodeMaterialConnectionPoint;
  62591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62593. autoConfigure(material: NodeMaterial): void;
  62594. protected _buildBlock(state: NodeMaterialBuildState): this;
  62595. protected _dumpPropertiesCode(): string;
  62596. serialize(): any;
  62597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62598. }
  62599. }
  62600. declare module BABYLON {
  62601. /**
  62602. * Block used to discard a pixel if a value is smaller than a cutoff
  62603. */
  62604. export class DiscardBlock extends NodeMaterialBlock {
  62605. /**
  62606. * Create a new DiscardBlock
  62607. * @param name defines the block name
  62608. */
  62609. constructor(name: string);
  62610. /**
  62611. * Gets the current class name
  62612. * @returns the class name
  62613. */
  62614. getClassName(): string;
  62615. /**
  62616. * Gets the color input component
  62617. */
  62618. get value(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the cutoff input component
  62621. */
  62622. get cutoff(): NodeMaterialConnectionPoint;
  62623. protected _buildBlock(state: NodeMaterialBuildState): this;
  62624. }
  62625. }
  62626. declare module BABYLON {
  62627. /**
  62628. * Block used to test if the fragment shader is front facing
  62629. */
  62630. export class FrontFacingBlock extends NodeMaterialBlock {
  62631. /**
  62632. * Creates a new FrontFacingBlock
  62633. * @param name defines the block name
  62634. */
  62635. constructor(name: string);
  62636. /**
  62637. * Gets the current class name
  62638. * @returns the class name
  62639. */
  62640. getClassName(): string;
  62641. /**
  62642. * Gets the output component
  62643. */
  62644. get output(): NodeMaterialConnectionPoint;
  62645. protected _buildBlock(state: NodeMaterialBuildState): this;
  62646. }
  62647. }
  62648. declare module BABYLON {
  62649. /**
  62650. * Block used to get the derivative value on x and y of a given input
  62651. */
  62652. export class DerivativeBlock extends NodeMaterialBlock {
  62653. /**
  62654. * Create a new DerivativeBlock
  62655. * @param name defines the block name
  62656. */
  62657. constructor(name: string);
  62658. /**
  62659. * Gets the current class name
  62660. * @returns the class name
  62661. */
  62662. getClassName(): string;
  62663. /**
  62664. * Gets the input component
  62665. */
  62666. get input(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the derivative output on x
  62669. */
  62670. get dx(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the derivative output on y
  62673. */
  62674. get dy(): NodeMaterialConnectionPoint;
  62675. protected _buildBlock(state: NodeMaterialBuildState): this;
  62676. }
  62677. }
  62678. declare module BABYLON {
  62679. /**
  62680. * Block used to make gl_FragCoord available
  62681. */
  62682. export class FragCoordBlock extends NodeMaterialBlock {
  62683. /**
  62684. * Creates a new FragCoordBlock
  62685. * @param name defines the block name
  62686. */
  62687. constructor(name: string);
  62688. /**
  62689. * Gets the current class name
  62690. * @returns the class name
  62691. */
  62692. getClassName(): string;
  62693. /**
  62694. * Gets the xy component
  62695. */
  62696. get xy(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the xyz component
  62699. */
  62700. get xyz(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the xyzw component
  62703. */
  62704. get xyzw(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the x component
  62707. */
  62708. get x(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the y component
  62711. */
  62712. get y(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the z component
  62715. */
  62716. get z(): NodeMaterialConnectionPoint;
  62717. /**
  62718. * Gets the w component
  62719. */
  62720. get output(): NodeMaterialConnectionPoint;
  62721. protected writeOutputs(state: NodeMaterialBuildState): string;
  62722. protected _buildBlock(state: NodeMaterialBuildState): this;
  62723. }
  62724. }
  62725. declare module BABYLON {
  62726. /**
  62727. * Block used to get the screen sizes
  62728. */
  62729. export class ScreenSizeBlock extends NodeMaterialBlock {
  62730. private _varName;
  62731. private _scene;
  62732. /**
  62733. * Creates a new ScreenSizeBlock
  62734. * @param name defines the block name
  62735. */
  62736. constructor(name: string);
  62737. /**
  62738. * Gets the current class name
  62739. * @returns the class name
  62740. */
  62741. getClassName(): string;
  62742. /**
  62743. * Gets the xy component
  62744. */
  62745. get xy(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the x component
  62748. */
  62749. get x(): NodeMaterialConnectionPoint;
  62750. /**
  62751. * Gets the y component
  62752. */
  62753. get y(): NodeMaterialConnectionPoint;
  62754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62755. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62756. protected _buildBlock(state: NodeMaterialBuildState): this;
  62757. }
  62758. }
  62759. declare module BABYLON {
  62760. /**
  62761. * Block used to add support for scene fog
  62762. */
  62763. export class FogBlock extends NodeMaterialBlock {
  62764. private _fogDistanceName;
  62765. private _fogParameters;
  62766. /**
  62767. * Create a new FogBlock
  62768. * @param name defines the block name
  62769. */
  62770. constructor(name: string);
  62771. /**
  62772. * Gets the current class name
  62773. * @returns the class name
  62774. */
  62775. getClassName(): string;
  62776. /**
  62777. * Gets the world position input component
  62778. */
  62779. get worldPosition(): NodeMaterialConnectionPoint;
  62780. /**
  62781. * Gets the view input component
  62782. */
  62783. get view(): NodeMaterialConnectionPoint;
  62784. /**
  62785. * Gets the color input component
  62786. */
  62787. get input(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the fog color input component
  62790. */
  62791. get fogColor(): NodeMaterialConnectionPoint;
  62792. /**
  62793. * Gets the output component
  62794. */
  62795. get output(): NodeMaterialConnectionPoint;
  62796. autoConfigure(material: NodeMaterial): void;
  62797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62799. protected _buildBlock(state: NodeMaterialBuildState): this;
  62800. }
  62801. }
  62802. declare module BABYLON {
  62803. /**
  62804. * Block used to add light in the fragment shader
  62805. */
  62806. export class LightBlock extends NodeMaterialBlock {
  62807. private _lightId;
  62808. /**
  62809. * Gets or sets the light associated with this block
  62810. */
  62811. light: Nullable<Light>;
  62812. /**
  62813. * Create a new LightBlock
  62814. * @param name defines the block name
  62815. */
  62816. constructor(name: string);
  62817. /**
  62818. * Gets the current class name
  62819. * @returns the class name
  62820. */
  62821. getClassName(): string;
  62822. /**
  62823. * Gets the world position input component
  62824. */
  62825. get worldPosition(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the world normal input component
  62828. */
  62829. get worldNormal(): NodeMaterialConnectionPoint;
  62830. /**
  62831. * Gets the camera (or eye) position component
  62832. */
  62833. get cameraPosition(): NodeMaterialConnectionPoint;
  62834. /**
  62835. * Gets the glossiness component
  62836. */
  62837. get glossiness(): NodeMaterialConnectionPoint;
  62838. /**
  62839. * Gets the glossinness power component
  62840. */
  62841. get glossPower(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the diffuse color component
  62844. */
  62845. get diffuseColor(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the specular color component
  62848. */
  62849. get specularColor(): NodeMaterialConnectionPoint;
  62850. /**
  62851. * Gets the diffuse output component
  62852. */
  62853. get diffuseOutput(): NodeMaterialConnectionPoint;
  62854. /**
  62855. * Gets the specular output component
  62856. */
  62857. get specularOutput(): NodeMaterialConnectionPoint;
  62858. /**
  62859. * Gets the shadow output component
  62860. */
  62861. get shadow(): NodeMaterialConnectionPoint;
  62862. autoConfigure(material: NodeMaterial): void;
  62863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62864. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62865. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62866. private _injectVertexCode;
  62867. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62868. serialize(): any;
  62869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62870. }
  62871. }
  62872. declare module BABYLON {
  62873. /**
  62874. * Block used to read a reflection texture from a sampler
  62875. */
  62876. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62877. /**
  62878. * Create a new ReflectionTextureBlock
  62879. * @param name defines the block name
  62880. */
  62881. constructor(name: string);
  62882. /**
  62883. * Gets the current class name
  62884. * @returns the class name
  62885. */
  62886. getClassName(): string;
  62887. /**
  62888. * Gets the world position input component
  62889. */
  62890. get position(): NodeMaterialConnectionPoint;
  62891. /**
  62892. * Gets the world position input component
  62893. */
  62894. get worldPosition(): NodeMaterialConnectionPoint;
  62895. /**
  62896. * Gets the world normal input component
  62897. */
  62898. get worldNormal(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the world input component
  62901. */
  62902. get world(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the camera (or eye) position component
  62905. */
  62906. get cameraPosition(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the view input component
  62909. */
  62910. get view(): NodeMaterialConnectionPoint;
  62911. /**
  62912. * Gets the rgb output component
  62913. */
  62914. get rgb(): NodeMaterialConnectionPoint;
  62915. /**
  62916. * Gets the rgba output component
  62917. */
  62918. get rgba(): NodeMaterialConnectionPoint;
  62919. /**
  62920. * Gets the r output component
  62921. */
  62922. get r(): NodeMaterialConnectionPoint;
  62923. /**
  62924. * Gets the g output component
  62925. */
  62926. get g(): NodeMaterialConnectionPoint;
  62927. /**
  62928. * Gets the b output component
  62929. */
  62930. get b(): NodeMaterialConnectionPoint;
  62931. /**
  62932. * Gets the a output component
  62933. */
  62934. get a(): NodeMaterialConnectionPoint;
  62935. autoConfigure(material: NodeMaterial): void;
  62936. protected _buildBlock(state: NodeMaterialBuildState): this;
  62937. }
  62938. }
  62939. declare module BABYLON {
  62940. /**
  62941. * Block used to add 2 vectors
  62942. */
  62943. export class AddBlock extends NodeMaterialBlock {
  62944. /**
  62945. * Creates a new AddBlock
  62946. * @param name defines the block name
  62947. */
  62948. constructor(name: string);
  62949. /**
  62950. * Gets the current class name
  62951. * @returns the class name
  62952. */
  62953. getClassName(): string;
  62954. /**
  62955. * Gets the left operand input component
  62956. */
  62957. get left(): NodeMaterialConnectionPoint;
  62958. /**
  62959. * Gets the right operand input component
  62960. */
  62961. get right(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the output component
  62964. */
  62965. get output(): NodeMaterialConnectionPoint;
  62966. protected _buildBlock(state: NodeMaterialBuildState): this;
  62967. }
  62968. }
  62969. declare module BABYLON {
  62970. /**
  62971. * Block used to scale a vector by a float
  62972. */
  62973. export class ScaleBlock extends NodeMaterialBlock {
  62974. /**
  62975. * Creates a new ScaleBlock
  62976. * @param name defines the block name
  62977. */
  62978. constructor(name: string);
  62979. /**
  62980. * Gets the current class name
  62981. * @returns the class name
  62982. */
  62983. getClassName(): string;
  62984. /**
  62985. * Gets the input component
  62986. */
  62987. get input(): NodeMaterialConnectionPoint;
  62988. /**
  62989. * Gets the factor input component
  62990. */
  62991. get factor(): NodeMaterialConnectionPoint;
  62992. /**
  62993. * Gets the output component
  62994. */
  62995. get output(): NodeMaterialConnectionPoint;
  62996. protected _buildBlock(state: NodeMaterialBuildState): this;
  62997. }
  62998. }
  62999. declare module BABYLON {
  63000. /**
  63001. * Block used to clamp a float
  63002. */
  63003. export class ClampBlock extends NodeMaterialBlock {
  63004. /** Gets or sets the minimum range */
  63005. minimum: number;
  63006. /** Gets or sets the maximum range */
  63007. maximum: number;
  63008. /**
  63009. * Creates a new ClampBlock
  63010. * @param name defines the block name
  63011. */
  63012. constructor(name: string);
  63013. /**
  63014. * Gets the current class name
  63015. * @returns the class name
  63016. */
  63017. getClassName(): string;
  63018. /**
  63019. * Gets the value input component
  63020. */
  63021. get value(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the output component
  63024. */
  63025. get output(): NodeMaterialConnectionPoint;
  63026. protected _buildBlock(state: NodeMaterialBuildState): this;
  63027. protected _dumpPropertiesCode(): string;
  63028. serialize(): any;
  63029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63030. }
  63031. }
  63032. declare module BABYLON {
  63033. /**
  63034. * Block used to apply a cross product between 2 vectors
  63035. */
  63036. export class CrossBlock extends NodeMaterialBlock {
  63037. /**
  63038. * Creates a new CrossBlock
  63039. * @param name defines the block name
  63040. */
  63041. constructor(name: string);
  63042. /**
  63043. * Gets the current class name
  63044. * @returns the class name
  63045. */
  63046. getClassName(): string;
  63047. /**
  63048. * Gets the left operand input component
  63049. */
  63050. get left(): NodeMaterialConnectionPoint;
  63051. /**
  63052. * Gets the right operand input component
  63053. */
  63054. get right(): NodeMaterialConnectionPoint;
  63055. /**
  63056. * Gets the output component
  63057. */
  63058. get output(): NodeMaterialConnectionPoint;
  63059. protected _buildBlock(state: NodeMaterialBuildState): this;
  63060. }
  63061. }
  63062. declare module BABYLON {
  63063. /**
  63064. * Block used to apply a dot product between 2 vectors
  63065. */
  63066. export class DotBlock extends NodeMaterialBlock {
  63067. /**
  63068. * Creates a new DotBlock
  63069. * @param name defines the block name
  63070. */
  63071. constructor(name: string);
  63072. /**
  63073. * Gets the current class name
  63074. * @returns the class name
  63075. */
  63076. getClassName(): string;
  63077. /**
  63078. * Gets the left operand input component
  63079. */
  63080. get left(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the right operand input component
  63083. */
  63084. get right(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the output component
  63087. */
  63088. get output(): NodeMaterialConnectionPoint;
  63089. protected _buildBlock(state: NodeMaterialBuildState): this;
  63090. }
  63091. }
  63092. declare module BABYLON {
  63093. /**
  63094. * Block used to normalize a vector
  63095. */
  63096. export class NormalizeBlock extends NodeMaterialBlock {
  63097. /**
  63098. * Creates a new NormalizeBlock
  63099. * @param name defines the block name
  63100. */
  63101. constructor(name: string);
  63102. /**
  63103. * Gets the current class name
  63104. * @returns the class name
  63105. */
  63106. getClassName(): string;
  63107. /**
  63108. * Gets the input component
  63109. */
  63110. get input(): NodeMaterialConnectionPoint;
  63111. /**
  63112. * Gets the output component
  63113. */
  63114. get output(): NodeMaterialConnectionPoint;
  63115. protected _buildBlock(state: NodeMaterialBuildState): this;
  63116. }
  63117. }
  63118. declare module BABYLON {
  63119. /**
  63120. * Operations supported by the Trigonometry block
  63121. */
  63122. export enum TrigonometryBlockOperations {
  63123. /** Cos */
  63124. Cos = 0,
  63125. /** Sin */
  63126. Sin = 1,
  63127. /** Abs */
  63128. Abs = 2,
  63129. /** Exp */
  63130. Exp = 3,
  63131. /** Exp2 */
  63132. Exp2 = 4,
  63133. /** Round */
  63134. Round = 5,
  63135. /** Floor */
  63136. Floor = 6,
  63137. /** Ceiling */
  63138. Ceiling = 7,
  63139. /** Square root */
  63140. Sqrt = 8,
  63141. /** Log */
  63142. Log = 9,
  63143. /** Tangent */
  63144. Tan = 10,
  63145. /** Arc tangent */
  63146. ArcTan = 11,
  63147. /** Arc cosinus */
  63148. ArcCos = 12,
  63149. /** Arc sinus */
  63150. ArcSin = 13,
  63151. /** Fraction */
  63152. Fract = 14,
  63153. /** Sign */
  63154. Sign = 15,
  63155. /** To radians (from degrees) */
  63156. Radians = 16,
  63157. /** To degrees (from radians) */
  63158. Degrees = 17
  63159. }
  63160. /**
  63161. * Block used to apply trigonometry operation to floats
  63162. */
  63163. export class TrigonometryBlock extends NodeMaterialBlock {
  63164. /**
  63165. * Gets or sets the operation applied by the block
  63166. */
  63167. operation: TrigonometryBlockOperations;
  63168. /**
  63169. * Creates a new TrigonometryBlock
  63170. * @param name defines the block name
  63171. */
  63172. constructor(name: string);
  63173. /**
  63174. * Gets the current class name
  63175. * @returns the class name
  63176. */
  63177. getClassName(): string;
  63178. /**
  63179. * Gets the input component
  63180. */
  63181. get input(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the output component
  63184. */
  63185. get output(): NodeMaterialConnectionPoint;
  63186. protected _buildBlock(state: NodeMaterialBuildState): this;
  63187. serialize(): any;
  63188. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63189. protected _dumpPropertiesCode(): string;
  63190. }
  63191. }
  63192. declare module BABYLON {
  63193. /**
  63194. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63195. */
  63196. export class ColorMergerBlock extends NodeMaterialBlock {
  63197. /**
  63198. * Create a new ColorMergerBlock
  63199. * @param name defines the block name
  63200. */
  63201. constructor(name: string);
  63202. /**
  63203. * Gets the current class name
  63204. * @returns the class name
  63205. */
  63206. getClassName(): string;
  63207. /**
  63208. * Gets the rgb component (input)
  63209. */
  63210. get rgbIn(): NodeMaterialConnectionPoint;
  63211. /**
  63212. * Gets the r component (input)
  63213. */
  63214. get r(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the g component (input)
  63217. */
  63218. get g(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the b component (input)
  63221. */
  63222. get b(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the a component (input)
  63225. */
  63226. get a(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the rgba component (output)
  63229. */
  63230. get rgba(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the rgb component (output)
  63233. */
  63234. get rgbOut(): NodeMaterialConnectionPoint;
  63235. /**
  63236. * Gets the rgb component (output)
  63237. * @deprecated Please use rgbOut instead.
  63238. */
  63239. get rgb(): NodeMaterialConnectionPoint;
  63240. protected _buildBlock(state: NodeMaterialBuildState): this;
  63241. }
  63242. }
  63243. declare module BABYLON {
  63244. /**
  63245. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63246. */
  63247. export class VectorSplitterBlock extends NodeMaterialBlock {
  63248. /**
  63249. * Create a new VectorSplitterBlock
  63250. * @param name defines the block name
  63251. */
  63252. constructor(name: string);
  63253. /**
  63254. * Gets the current class name
  63255. * @returns the class name
  63256. */
  63257. getClassName(): string;
  63258. /**
  63259. * Gets the xyzw component (input)
  63260. */
  63261. get xyzw(): NodeMaterialConnectionPoint;
  63262. /**
  63263. * Gets the xyz component (input)
  63264. */
  63265. get xyzIn(): NodeMaterialConnectionPoint;
  63266. /**
  63267. * Gets the xy component (input)
  63268. */
  63269. get xyIn(): NodeMaterialConnectionPoint;
  63270. /**
  63271. * Gets the xyz component (output)
  63272. */
  63273. get xyzOut(): NodeMaterialConnectionPoint;
  63274. /**
  63275. * Gets the xy component (output)
  63276. */
  63277. get xyOut(): NodeMaterialConnectionPoint;
  63278. /**
  63279. * Gets the x component (output)
  63280. */
  63281. get x(): NodeMaterialConnectionPoint;
  63282. /**
  63283. * Gets the y component (output)
  63284. */
  63285. get y(): NodeMaterialConnectionPoint;
  63286. /**
  63287. * Gets the z component (output)
  63288. */
  63289. get z(): NodeMaterialConnectionPoint;
  63290. /**
  63291. * Gets the w component (output)
  63292. */
  63293. get w(): NodeMaterialConnectionPoint;
  63294. protected _inputRename(name: string): string;
  63295. protected _outputRename(name: string): string;
  63296. protected _buildBlock(state: NodeMaterialBuildState): this;
  63297. }
  63298. }
  63299. declare module BABYLON {
  63300. /**
  63301. * Block used to lerp between 2 values
  63302. */
  63303. export class LerpBlock extends NodeMaterialBlock {
  63304. /**
  63305. * Creates a new LerpBlock
  63306. * @param name defines the block name
  63307. */
  63308. constructor(name: string);
  63309. /**
  63310. * Gets the current class name
  63311. * @returns the class name
  63312. */
  63313. getClassName(): string;
  63314. /**
  63315. * Gets the left operand input component
  63316. */
  63317. get left(): NodeMaterialConnectionPoint;
  63318. /**
  63319. * Gets the right operand input component
  63320. */
  63321. get right(): NodeMaterialConnectionPoint;
  63322. /**
  63323. * Gets the gradient operand input component
  63324. */
  63325. get gradient(): NodeMaterialConnectionPoint;
  63326. /**
  63327. * Gets the output component
  63328. */
  63329. get output(): NodeMaterialConnectionPoint;
  63330. protected _buildBlock(state: NodeMaterialBuildState): this;
  63331. }
  63332. }
  63333. declare module BABYLON {
  63334. /**
  63335. * Block used to divide 2 vectors
  63336. */
  63337. export class DivideBlock extends NodeMaterialBlock {
  63338. /**
  63339. * Creates a new DivideBlock
  63340. * @param name defines the block name
  63341. */
  63342. constructor(name: string);
  63343. /**
  63344. * Gets the current class name
  63345. * @returns the class name
  63346. */
  63347. getClassName(): string;
  63348. /**
  63349. * Gets the left operand input component
  63350. */
  63351. get left(): NodeMaterialConnectionPoint;
  63352. /**
  63353. * Gets the right operand input component
  63354. */
  63355. get right(): NodeMaterialConnectionPoint;
  63356. /**
  63357. * Gets the output component
  63358. */
  63359. get output(): NodeMaterialConnectionPoint;
  63360. protected _buildBlock(state: NodeMaterialBuildState): this;
  63361. }
  63362. }
  63363. declare module BABYLON {
  63364. /**
  63365. * Block used to subtract 2 vectors
  63366. */
  63367. export class SubtractBlock extends NodeMaterialBlock {
  63368. /**
  63369. * Creates a new SubtractBlock
  63370. * @param name defines the block name
  63371. */
  63372. constructor(name: string);
  63373. /**
  63374. * Gets the current class name
  63375. * @returns the class name
  63376. */
  63377. getClassName(): string;
  63378. /**
  63379. * Gets the left operand input component
  63380. */
  63381. get left(): NodeMaterialConnectionPoint;
  63382. /**
  63383. * Gets the right operand input component
  63384. */
  63385. get right(): NodeMaterialConnectionPoint;
  63386. /**
  63387. * Gets the output component
  63388. */
  63389. get output(): NodeMaterialConnectionPoint;
  63390. protected _buildBlock(state: NodeMaterialBuildState): this;
  63391. }
  63392. }
  63393. declare module BABYLON {
  63394. /**
  63395. * Block used to step a value
  63396. */
  63397. export class StepBlock extends NodeMaterialBlock {
  63398. /**
  63399. * Creates a new StepBlock
  63400. * @param name defines the block name
  63401. */
  63402. constructor(name: string);
  63403. /**
  63404. * Gets the current class name
  63405. * @returns the class name
  63406. */
  63407. getClassName(): string;
  63408. /**
  63409. * Gets the value operand input component
  63410. */
  63411. get value(): NodeMaterialConnectionPoint;
  63412. /**
  63413. * Gets the edge operand input component
  63414. */
  63415. get edge(): NodeMaterialConnectionPoint;
  63416. /**
  63417. * Gets the output component
  63418. */
  63419. get output(): NodeMaterialConnectionPoint;
  63420. protected _buildBlock(state: NodeMaterialBuildState): this;
  63421. }
  63422. }
  63423. declare module BABYLON {
  63424. /**
  63425. * Block used to get the opposite (1 - x) of a value
  63426. */
  63427. export class OneMinusBlock extends NodeMaterialBlock {
  63428. /**
  63429. * Creates a new OneMinusBlock
  63430. * @param name defines the block name
  63431. */
  63432. constructor(name: string);
  63433. /**
  63434. * Gets the current class name
  63435. * @returns the class name
  63436. */
  63437. getClassName(): string;
  63438. /**
  63439. * Gets the input component
  63440. */
  63441. get input(): NodeMaterialConnectionPoint;
  63442. /**
  63443. * Gets the output component
  63444. */
  63445. get output(): NodeMaterialConnectionPoint;
  63446. protected _buildBlock(state: NodeMaterialBuildState): this;
  63447. }
  63448. }
  63449. declare module BABYLON {
  63450. /**
  63451. * Block used to get the view direction
  63452. */
  63453. export class ViewDirectionBlock extends NodeMaterialBlock {
  63454. /**
  63455. * Creates a new ViewDirectionBlock
  63456. * @param name defines the block name
  63457. */
  63458. constructor(name: string);
  63459. /**
  63460. * Gets the current class name
  63461. * @returns the class name
  63462. */
  63463. getClassName(): string;
  63464. /**
  63465. * Gets the world position component
  63466. */
  63467. get worldPosition(): NodeMaterialConnectionPoint;
  63468. /**
  63469. * Gets the camera position component
  63470. */
  63471. get cameraPosition(): NodeMaterialConnectionPoint;
  63472. /**
  63473. * Gets the output component
  63474. */
  63475. get output(): NodeMaterialConnectionPoint;
  63476. autoConfigure(material: NodeMaterial): void;
  63477. protected _buildBlock(state: NodeMaterialBuildState): this;
  63478. }
  63479. }
  63480. declare module BABYLON {
  63481. /**
  63482. * Block used to compute fresnel value
  63483. */
  63484. export class FresnelBlock extends NodeMaterialBlock {
  63485. /**
  63486. * Create a new FresnelBlock
  63487. * @param name defines the block name
  63488. */
  63489. constructor(name: string);
  63490. /**
  63491. * Gets the current class name
  63492. * @returns the class name
  63493. */
  63494. getClassName(): string;
  63495. /**
  63496. * Gets the world normal input component
  63497. */
  63498. get worldNormal(): NodeMaterialConnectionPoint;
  63499. /**
  63500. * Gets the view direction input component
  63501. */
  63502. get viewDirection(): NodeMaterialConnectionPoint;
  63503. /**
  63504. * Gets the bias input component
  63505. */
  63506. get bias(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the camera (or eye) position component
  63509. */
  63510. get power(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the fresnel output component
  63513. */
  63514. get fresnel(): NodeMaterialConnectionPoint;
  63515. autoConfigure(material: NodeMaterial): void;
  63516. protected _buildBlock(state: NodeMaterialBuildState): this;
  63517. }
  63518. }
  63519. declare module BABYLON {
  63520. /**
  63521. * Block used to get the max of 2 values
  63522. */
  63523. export class MaxBlock extends NodeMaterialBlock {
  63524. /**
  63525. * Creates a new MaxBlock
  63526. * @param name defines the block name
  63527. */
  63528. constructor(name: string);
  63529. /**
  63530. * Gets the current class name
  63531. * @returns the class name
  63532. */
  63533. getClassName(): string;
  63534. /**
  63535. * Gets the left operand input component
  63536. */
  63537. get left(): NodeMaterialConnectionPoint;
  63538. /**
  63539. * Gets the right operand input component
  63540. */
  63541. get right(): NodeMaterialConnectionPoint;
  63542. /**
  63543. * Gets the output component
  63544. */
  63545. get output(): NodeMaterialConnectionPoint;
  63546. protected _buildBlock(state: NodeMaterialBuildState): this;
  63547. }
  63548. }
  63549. declare module BABYLON {
  63550. /**
  63551. * Block used to get the min of 2 values
  63552. */
  63553. export class MinBlock extends NodeMaterialBlock {
  63554. /**
  63555. * Creates a new MinBlock
  63556. * @param name defines the block name
  63557. */
  63558. constructor(name: string);
  63559. /**
  63560. * Gets the current class name
  63561. * @returns the class name
  63562. */
  63563. getClassName(): string;
  63564. /**
  63565. * Gets the left operand input component
  63566. */
  63567. get left(): NodeMaterialConnectionPoint;
  63568. /**
  63569. * Gets the right operand input component
  63570. */
  63571. get right(): NodeMaterialConnectionPoint;
  63572. /**
  63573. * Gets the output component
  63574. */
  63575. get output(): NodeMaterialConnectionPoint;
  63576. protected _buildBlock(state: NodeMaterialBuildState): this;
  63577. }
  63578. }
  63579. declare module BABYLON {
  63580. /**
  63581. * Block used to get the distance between 2 values
  63582. */
  63583. export class DistanceBlock extends NodeMaterialBlock {
  63584. /**
  63585. * Creates a new DistanceBlock
  63586. * @param name defines the block name
  63587. */
  63588. constructor(name: string);
  63589. /**
  63590. * Gets the current class name
  63591. * @returns the class name
  63592. */
  63593. getClassName(): string;
  63594. /**
  63595. * Gets the left operand input component
  63596. */
  63597. get left(): NodeMaterialConnectionPoint;
  63598. /**
  63599. * Gets the right operand input component
  63600. */
  63601. get right(): NodeMaterialConnectionPoint;
  63602. /**
  63603. * Gets the output component
  63604. */
  63605. get output(): NodeMaterialConnectionPoint;
  63606. protected _buildBlock(state: NodeMaterialBuildState): this;
  63607. }
  63608. }
  63609. declare module BABYLON {
  63610. /**
  63611. * Block used to get the length of a vector
  63612. */
  63613. export class LengthBlock extends NodeMaterialBlock {
  63614. /**
  63615. * Creates a new LengthBlock
  63616. * @param name defines the block name
  63617. */
  63618. constructor(name: string);
  63619. /**
  63620. * Gets the current class name
  63621. * @returns the class name
  63622. */
  63623. getClassName(): string;
  63624. /**
  63625. * Gets the value input component
  63626. */
  63627. get value(): NodeMaterialConnectionPoint;
  63628. /**
  63629. * Gets the output component
  63630. */
  63631. get output(): NodeMaterialConnectionPoint;
  63632. protected _buildBlock(state: NodeMaterialBuildState): this;
  63633. }
  63634. }
  63635. declare module BABYLON {
  63636. /**
  63637. * Block used to get negative version of a value (i.e. x * -1)
  63638. */
  63639. export class NegateBlock extends NodeMaterialBlock {
  63640. /**
  63641. * Creates a new NegateBlock
  63642. * @param name defines the block name
  63643. */
  63644. constructor(name: string);
  63645. /**
  63646. * Gets the current class name
  63647. * @returns the class name
  63648. */
  63649. getClassName(): string;
  63650. /**
  63651. * Gets the value input component
  63652. */
  63653. get value(): NodeMaterialConnectionPoint;
  63654. /**
  63655. * Gets the output component
  63656. */
  63657. get output(): NodeMaterialConnectionPoint;
  63658. protected _buildBlock(state: NodeMaterialBuildState): this;
  63659. }
  63660. }
  63661. declare module BABYLON {
  63662. /**
  63663. * Block used to get the value of the first parameter raised to the power of the second
  63664. */
  63665. export class PowBlock extends NodeMaterialBlock {
  63666. /**
  63667. * Creates a new PowBlock
  63668. * @param name defines the block name
  63669. */
  63670. constructor(name: string);
  63671. /**
  63672. * Gets the current class name
  63673. * @returns the class name
  63674. */
  63675. getClassName(): string;
  63676. /**
  63677. * Gets the value operand input component
  63678. */
  63679. get value(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the power operand input component
  63682. */
  63683. get power(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the output component
  63686. */
  63687. get output(): NodeMaterialConnectionPoint;
  63688. protected _buildBlock(state: NodeMaterialBuildState): this;
  63689. }
  63690. }
  63691. declare module BABYLON {
  63692. /**
  63693. * Block used to get a random number
  63694. */
  63695. export class RandomNumberBlock extends NodeMaterialBlock {
  63696. /**
  63697. * Creates a new RandomNumberBlock
  63698. * @param name defines the block name
  63699. */
  63700. constructor(name: string);
  63701. /**
  63702. * Gets the current class name
  63703. * @returns the class name
  63704. */
  63705. getClassName(): string;
  63706. /**
  63707. * Gets the seed input component
  63708. */
  63709. get seed(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the output component
  63712. */
  63713. get output(): NodeMaterialConnectionPoint;
  63714. protected _buildBlock(state: NodeMaterialBuildState): this;
  63715. }
  63716. }
  63717. declare module BABYLON {
  63718. /**
  63719. * Block used to compute arc tangent of 2 values
  63720. */
  63721. export class ArcTan2Block extends NodeMaterialBlock {
  63722. /**
  63723. * Creates a new ArcTan2Block
  63724. * @param name defines the block name
  63725. */
  63726. constructor(name: string);
  63727. /**
  63728. * Gets the current class name
  63729. * @returns the class name
  63730. */
  63731. getClassName(): string;
  63732. /**
  63733. * Gets the x operand input component
  63734. */
  63735. get x(): NodeMaterialConnectionPoint;
  63736. /**
  63737. * Gets the y operand input component
  63738. */
  63739. get y(): NodeMaterialConnectionPoint;
  63740. /**
  63741. * Gets the output component
  63742. */
  63743. get output(): NodeMaterialConnectionPoint;
  63744. protected _buildBlock(state: NodeMaterialBuildState): this;
  63745. }
  63746. }
  63747. declare module BABYLON {
  63748. /**
  63749. * Block used to smooth step a value
  63750. */
  63751. export class SmoothStepBlock extends NodeMaterialBlock {
  63752. /**
  63753. * Creates a new SmoothStepBlock
  63754. * @param name defines the block name
  63755. */
  63756. constructor(name: string);
  63757. /**
  63758. * Gets the current class name
  63759. * @returns the class name
  63760. */
  63761. getClassName(): string;
  63762. /**
  63763. * Gets the value operand input component
  63764. */
  63765. get value(): NodeMaterialConnectionPoint;
  63766. /**
  63767. * Gets the first edge operand input component
  63768. */
  63769. get edge0(): NodeMaterialConnectionPoint;
  63770. /**
  63771. * Gets the second edge operand input component
  63772. */
  63773. get edge1(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the output component
  63776. */
  63777. get output(): NodeMaterialConnectionPoint;
  63778. protected _buildBlock(state: NodeMaterialBuildState): this;
  63779. }
  63780. }
  63781. declare module BABYLON {
  63782. /**
  63783. * Block used to get the reciprocal (1 / x) of a value
  63784. */
  63785. export class ReciprocalBlock extends NodeMaterialBlock {
  63786. /**
  63787. * Creates a new ReciprocalBlock
  63788. * @param name defines the block name
  63789. */
  63790. constructor(name: string);
  63791. /**
  63792. * Gets the current class name
  63793. * @returns the class name
  63794. */
  63795. getClassName(): string;
  63796. /**
  63797. * Gets the input component
  63798. */
  63799. get input(): NodeMaterialConnectionPoint;
  63800. /**
  63801. * Gets the output component
  63802. */
  63803. get output(): NodeMaterialConnectionPoint;
  63804. protected _buildBlock(state: NodeMaterialBuildState): this;
  63805. }
  63806. }
  63807. declare module BABYLON {
  63808. /**
  63809. * Block used to replace a color by another one
  63810. */
  63811. export class ReplaceColorBlock extends NodeMaterialBlock {
  63812. /**
  63813. * Creates a new ReplaceColorBlock
  63814. * @param name defines the block name
  63815. */
  63816. constructor(name: string);
  63817. /**
  63818. * Gets the current class name
  63819. * @returns the class name
  63820. */
  63821. getClassName(): string;
  63822. /**
  63823. * Gets the value input component
  63824. */
  63825. get value(): NodeMaterialConnectionPoint;
  63826. /**
  63827. * Gets the reference input component
  63828. */
  63829. get reference(): NodeMaterialConnectionPoint;
  63830. /**
  63831. * Gets the distance input component
  63832. */
  63833. get distance(): NodeMaterialConnectionPoint;
  63834. /**
  63835. * Gets the replacement input component
  63836. */
  63837. get replacement(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the output component
  63840. */
  63841. get output(): NodeMaterialConnectionPoint;
  63842. protected _buildBlock(state: NodeMaterialBuildState): this;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * Block used to posterize a value
  63848. * @see https://en.wikipedia.org/wiki/Posterization
  63849. */
  63850. export class PosterizeBlock extends NodeMaterialBlock {
  63851. /**
  63852. * Creates a new PosterizeBlock
  63853. * @param name defines the block name
  63854. */
  63855. constructor(name: string);
  63856. /**
  63857. * Gets the current class name
  63858. * @returns the class name
  63859. */
  63860. getClassName(): string;
  63861. /**
  63862. * Gets the value input component
  63863. */
  63864. get value(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the steps input component
  63867. */
  63868. get steps(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the output component
  63871. */
  63872. get output(): NodeMaterialConnectionPoint;
  63873. protected _buildBlock(state: NodeMaterialBuildState): this;
  63874. }
  63875. }
  63876. declare module BABYLON {
  63877. /**
  63878. * Operations supported by the Wave block
  63879. */
  63880. export enum WaveBlockKind {
  63881. /** SawTooth */
  63882. SawTooth = 0,
  63883. /** Square */
  63884. Square = 1,
  63885. /** Triangle */
  63886. Triangle = 2
  63887. }
  63888. /**
  63889. * Block used to apply wave operation to floats
  63890. */
  63891. export class WaveBlock extends NodeMaterialBlock {
  63892. /**
  63893. * Gets or sets the kibnd of wave to be applied by the block
  63894. */
  63895. kind: WaveBlockKind;
  63896. /**
  63897. * Creates a new WaveBlock
  63898. * @param name defines the block name
  63899. */
  63900. constructor(name: string);
  63901. /**
  63902. * Gets the current class name
  63903. * @returns the class name
  63904. */
  63905. getClassName(): string;
  63906. /**
  63907. * Gets the input component
  63908. */
  63909. get input(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the output component
  63912. */
  63913. get output(): NodeMaterialConnectionPoint;
  63914. protected _buildBlock(state: NodeMaterialBuildState): this;
  63915. serialize(): any;
  63916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63917. }
  63918. }
  63919. declare module BABYLON {
  63920. /**
  63921. * Class used to store a color step for the GradientBlock
  63922. */
  63923. export class GradientBlockColorStep {
  63924. /**
  63925. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63926. */
  63927. step: number;
  63928. /**
  63929. * Gets or sets the color associated with this step
  63930. */
  63931. color: Color3;
  63932. /**
  63933. * Creates a new GradientBlockColorStep
  63934. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63935. * @param color defines the color associated with this step
  63936. */
  63937. constructor(
  63938. /**
  63939. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63940. */
  63941. step: number,
  63942. /**
  63943. * Gets or sets the color associated with this step
  63944. */
  63945. color: Color3);
  63946. }
  63947. /**
  63948. * Block used to return a color from a gradient based on an input value between 0 and 1
  63949. */
  63950. export class GradientBlock extends NodeMaterialBlock {
  63951. /**
  63952. * Gets or sets the list of color steps
  63953. */
  63954. colorSteps: GradientBlockColorStep[];
  63955. /**
  63956. * Creates a new GradientBlock
  63957. * @param name defines the block name
  63958. */
  63959. constructor(name: string);
  63960. /**
  63961. * Gets the current class name
  63962. * @returns the class name
  63963. */
  63964. getClassName(): string;
  63965. /**
  63966. * Gets the gradient input component
  63967. */
  63968. get gradient(): NodeMaterialConnectionPoint;
  63969. /**
  63970. * Gets the output component
  63971. */
  63972. get output(): NodeMaterialConnectionPoint;
  63973. private _writeColorConstant;
  63974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63975. serialize(): any;
  63976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63977. protected _dumpPropertiesCode(): string;
  63978. }
  63979. }
  63980. declare module BABYLON {
  63981. /**
  63982. * Block used to normalize lerp between 2 values
  63983. */
  63984. export class NLerpBlock extends NodeMaterialBlock {
  63985. /**
  63986. * Creates a new NLerpBlock
  63987. * @param name defines the block name
  63988. */
  63989. constructor(name: string);
  63990. /**
  63991. * Gets the current class name
  63992. * @returns the class name
  63993. */
  63994. getClassName(): string;
  63995. /**
  63996. * Gets the left operand input component
  63997. */
  63998. get left(): NodeMaterialConnectionPoint;
  63999. /**
  64000. * Gets the right operand input component
  64001. */
  64002. get right(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the gradient operand input component
  64005. */
  64006. get gradient(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the output component
  64009. */
  64010. get output(): NodeMaterialConnectionPoint;
  64011. protected _buildBlock(state: NodeMaterialBuildState): this;
  64012. }
  64013. }
  64014. declare module BABYLON {
  64015. /**
  64016. * block used to Generate a Worley Noise 3D Noise Pattern
  64017. */
  64018. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64019. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64020. manhattanDistance: boolean;
  64021. /**
  64022. * Creates a new WorleyNoise3DBlock
  64023. * @param name defines the block name
  64024. */
  64025. constructor(name: string);
  64026. /**
  64027. * Gets the current class name
  64028. * @returns the class name
  64029. */
  64030. getClassName(): string;
  64031. /**
  64032. * Gets the seed input component
  64033. */
  64034. get seed(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the jitter input component
  64037. */
  64038. get jitter(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the output component
  64041. */
  64042. get output(): NodeMaterialConnectionPoint;
  64043. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64044. /**
  64045. * Exposes the properties to the UI?
  64046. */
  64047. protected _dumpPropertiesCode(): string;
  64048. /**
  64049. * Exposes the properties to the Seralize?
  64050. */
  64051. serialize(): any;
  64052. /**
  64053. * Exposes the properties to the deseralize?
  64054. */
  64055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64056. }
  64057. }
  64058. declare module BABYLON {
  64059. /**
  64060. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64061. */
  64062. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64063. /**
  64064. * Creates a new SimplexPerlin3DBlock
  64065. * @param name defines the block name
  64066. */
  64067. constructor(name: string);
  64068. /**
  64069. * Gets the current class name
  64070. * @returns the class name
  64071. */
  64072. getClassName(): string;
  64073. /**
  64074. * Gets the seed operand input component
  64075. */
  64076. get seed(): NodeMaterialConnectionPoint;
  64077. /**
  64078. * Gets the output component
  64079. */
  64080. get output(): NodeMaterialConnectionPoint;
  64081. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64082. }
  64083. }
  64084. declare module BABYLON {
  64085. /**
  64086. * Block used to blend normals
  64087. */
  64088. export class NormalBlendBlock extends NodeMaterialBlock {
  64089. /**
  64090. * Creates a new NormalBlendBlock
  64091. * @param name defines the block name
  64092. */
  64093. constructor(name: string);
  64094. /**
  64095. * Gets the current class name
  64096. * @returns the class name
  64097. */
  64098. getClassName(): string;
  64099. /**
  64100. * Gets the first input component
  64101. */
  64102. get normalMap0(): NodeMaterialConnectionPoint;
  64103. /**
  64104. * Gets the second input component
  64105. */
  64106. get normalMap1(): NodeMaterialConnectionPoint;
  64107. /**
  64108. * Gets the output component
  64109. */
  64110. get output(): NodeMaterialConnectionPoint;
  64111. protected _buildBlock(state: NodeMaterialBuildState): this;
  64112. }
  64113. }
  64114. declare module BABYLON {
  64115. /**
  64116. * Block used to rotate a 2d vector by a given angle
  64117. */
  64118. export class Rotate2dBlock extends NodeMaterialBlock {
  64119. /**
  64120. * Creates a new Rotate2dBlock
  64121. * @param name defines the block name
  64122. */
  64123. constructor(name: string);
  64124. /**
  64125. * Gets the current class name
  64126. * @returns the class name
  64127. */
  64128. getClassName(): string;
  64129. /**
  64130. * Gets the input vector
  64131. */
  64132. get input(): NodeMaterialConnectionPoint;
  64133. /**
  64134. * Gets the input angle
  64135. */
  64136. get angle(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the output component
  64139. */
  64140. get output(): NodeMaterialConnectionPoint;
  64141. autoConfigure(material: NodeMaterial): void;
  64142. protected _buildBlock(state: NodeMaterialBuildState): this;
  64143. }
  64144. }
  64145. declare module BABYLON {
  64146. /**
  64147. * Block used to get the reflected vector from a direction and a normal
  64148. */
  64149. export class ReflectBlock extends NodeMaterialBlock {
  64150. /**
  64151. * Creates a new ReflectBlock
  64152. * @param name defines the block name
  64153. */
  64154. constructor(name: string);
  64155. /**
  64156. * Gets the current class name
  64157. * @returns the class name
  64158. */
  64159. getClassName(): string;
  64160. /**
  64161. * Gets the incident component
  64162. */
  64163. get incident(): NodeMaterialConnectionPoint;
  64164. /**
  64165. * Gets the normal component
  64166. */
  64167. get normal(): NodeMaterialConnectionPoint;
  64168. /**
  64169. * Gets the output component
  64170. */
  64171. get output(): NodeMaterialConnectionPoint;
  64172. protected _buildBlock(state: NodeMaterialBuildState): this;
  64173. }
  64174. }
  64175. declare module BABYLON {
  64176. /**
  64177. * Block used to get the refracted vector from a direction and a normal
  64178. */
  64179. export class RefractBlock extends NodeMaterialBlock {
  64180. /**
  64181. * Creates a new RefractBlock
  64182. * @param name defines the block name
  64183. */
  64184. constructor(name: string);
  64185. /**
  64186. * Gets the current class name
  64187. * @returns the class name
  64188. */
  64189. getClassName(): string;
  64190. /**
  64191. * Gets the incident component
  64192. */
  64193. get incident(): NodeMaterialConnectionPoint;
  64194. /**
  64195. * Gets the normal component
  64196. */
  64197. get normal(): NodeMaterialConnectionPoint;
  64198. /**
  64199. * Gets the index of refraction component
  64200. */
  64201. get ior(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the output component
  64204. */
  64205. get output(): NodeMaterialConnectionPoint;
  64206. protected _buildBlock(state: NodeMaterialBuildState): this;
  64207. }
  64208. }
  64209. declare module BABYLON {
  64210. /**
  64211. * Block used to desaturate a color
  64212. */
  64213. export class DesaturateBlock extends NodeMaterialBlock {
  64214. /**
  64215. * Creates a new DesaturateBlock
  64216. * @param name defines the block name
  64217. */
  64218. constructor(name: string);
  64219. /**
  64220. * Gets the current class name
  64221. * @returns the class name
  64222. */
  64223. getClassName(): string;
  64224. /**
  64225. * Gets the color operand input component
  64226. */
  64227. get color(): NodeMaterialConnectionPoint;
  64228. /**
  64229. * Gets the level operand input component
  64230. */
  64231. get level(): NodeMaterialConnectionPoint;
  64232. /**
  64233. * Gets the output component
  64234. */
  64235. get output(): NodeMaterialConnectionPoint;
  64236. protected _buildBlock(state: NodeMaterialBuildState): this;
  64237. }
  64238. }
  64239. declare module BABYLON {
  64240. /**
  64241. * Block used to implement the ambient occlusion module of the PBR material
  64242. */
  64243. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64244. /**
  64245. * Create a new AmbientOcclusionBlock
  64246. * @param name defines the block name
  64247. */
  64248. constructor(name: string);
  64249. /**
  64250. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64251. */
  64252. useAmbientInGrayScale: boolean;
  64253. /**
  64254. * Initialize the block and prepare the context for build
  64255. * @param state defines the state that will be used for the build
  64256. */
  64257. initialize(state: NodeMaterialBuildState): void;
  64258. /**
  64259. * Gets the current class name
  64260. * @returns the class name
  64261. */
  64262. getClassName(): string;
  64263. /**
  64264. * Gets the texture input component
  64265. */
  64266. get texture(): NodeMaterialConnectionPoint;
  64267. /**
  64268. * Gets the texture intensity component
  64269. */
  64270. get intensity(): NodeMaterialConnectionPoint;
  64271. /**
  64272. * Gets the direct light intensity input component
  64273. */
  64274. get directLightIntensity(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the ambient occlusion object output component
  64277. */
  64278. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64279. /**
  64280. * Gets the main code of the block (fragment side)
  64281. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64282. * @returns the shader code
  64283. */
  64284. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64286. protected _buildBlock(state: NodeMaterialBuildState): this;
  64287. protected _dumpPropertiesCode(): string;
  64288. serialize(): any;
  64289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64290. }
  64291. }
  64292. declare module BABYLON {
  64293. /**
  64294. * Block used to implement the reflection module of the PBR material
  64295. */
  64296. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64297. /** @hidden */
  64298. _defineLODReflectionAlpha: string;
  64299. /** @hidden */
  64300. _defineLinearSpecularReflection: string;
  64301. private _vEnvironmentIrradianceName;
  64302. /** @hidden */
  64303. _vReflectionMicrosurfaceInfosName: string;
  64304. /** @hidden */
  64305. _vReflectionInfosName: string;
  64306. /** @hidden */
  64307. _vReflectionFilteringInfoName: string;
  64308. private _scene;
  64309. /**
  64310. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64311. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64312. * It's less burden on the user side in the editor part.
  64313. */
  64314. /** @hidden */
  64315. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64316. /** @hidden */
  64317. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64318. /** @hidden */
  64319. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64320. /**
  64321. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64322. * diffuse part of the IBL.
  64323. */
  64324. useSphericalHarmonics: boolean;
  64325. /**
  64326. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64327. */
  64328. forceIrradianceInFragment: boolean;
  64329. /**
  64330. * Create a new ReflectionBlock
  64331. * @param name defines the block name
  64332. */
  64333. constructor(name: string);
  64334. /**
  64335. * Gets the current class name
  64336. * @returns the class name
  64337. */
  64338. getClassName(): string;
  64339. /**
  64340. * Gets the position input component
  64341. */
  64342. get position(): NodeMaterialConnectionPoint;
  64343. /**
  64344. * Gets the world position input component
  64345. */
  64346. get worldPosition(): NodeMaterialConnectionPoint;
  64347. /**
  64348. * Gets the world normal input component
  64349. */
  64350. get worldNormal(): NodeMaterialConnectionPoint;
  64351. /**
  64352. * Gets the world input component
  64353. */
  64354. get world(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the camera (or eye) position component
  64357. */
  64358. get cameraPosition(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the view input component
  64361. */
  64362. get view(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the color input component
  64365. */
  64366. get color(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the reflection object output component
  64369. */
  64370. get reflection(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64373. */
  64374. get hasTexture(): boolean;
  64375. /**
  64376. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64377. */
  64378. get reflectionColor(): string;
  64379. protected _getTexture(): Nullable<BaseTexture>;
  64380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64381. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64382. /**
  64383. * Gets the code to inject in the vertex shader
  64384. * @param state current state of the node material building
  64385. * @returns the shader code
  64386. */
  64387. handleVertexSide(state: NodeMaterialBuildState): string;
  64388. /**
  64389. * Gets the main code of the block (fragment side)
  64390. * @param state current state of the node material building
  64391. * @param normalVarName name of the existing variable corresponding to the normal
  64392. * @returns the shader code
  64393. */
  64394. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64395. protected _buildBlock(state: NodeMaterialBuildState): this;
  64396. protected _dumpPropertiesCode(): string;
  64397. serialize(): any;
  64398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64399. }
  64400. }
  64401. declare module BABYLON {
  64402. /**
  64403. * Block used to implement the sheen module of the PBR material
  64404. */
  64405. export class SheenBlock extends NodeMaterialBlock {
  64406. /**
  64407. * Create a new SheenBlock
  64408. * @param name defines the block name
  64409. */
  64410. constructor(name: string);
  64411. /**
  64412. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64413. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64414. * making it easier to setup and tweak the effect
  64415. */
  64416. albedoScaling: boolean;
  64417. /**
  64418. * Defines if the sheen is linked to the sheen color.
  64419. */
  64420. linkSheenWithAlbedo: boolean;
  64421. /**
  64422. * Initialize the block and prepare the context for build
  64423. * @param state defines the state that will be used for the build
  64424. */
  64425. initialize(state: NodeMaterialBuildState): void;
  64426. /**
  64427. * Gets the current class name
  64428. * @returns the class name
  64429. */
  64430. getClassName(): string;
  64431. /**
  64432. * Gets the intensity input component
  64433. */
  64434. get intensity(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the color input component
  64437. */
  64438. get color(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Gets the roughness input component
  64441. */
  64442. get roughness(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the sheen object output component
  64445. */
  64446. get sheen(): NodeMaterialConnectionPoint;
  64447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64448. /**
  64449. * Gets the main code of the block (fragment side)
  64450. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64451. * @returns the shader code
  64452. */
  64453. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64454. protected _buildBlock(state: NodeMaterialBuildState): this;
  64455. protected _dumpPropertiesCode(): string;
  64456. serialize(): any;
  64457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64458. }
  64459. }
  64460. declare module BABYLON {
  64461. /**
  64462. * Block used to implement the reflectivity module of the PBR material
  64463. */
  64464. export class ReflectivityBlock extends NodeMaterialBlock {
  64465. private _metallicReflectanceColor;
  64466. private _metallicF0Factor;
  64467. /** @hidden */
  64468. _vMetallicReflectanceFactorsName: string;
  64469. /**
  64470. * The property below is set by the main PBR block prior to calling methods of this class.
  64471. */
  64472. /** @hidden */
  64473. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64474. /**
  64475. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64476. */
  64477. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64478. /**
  64479. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64480. */
  64481. useMetallnessFromMetallicTextureBlue: boolean;
  64482. /**
  64483. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64484. */
  64485. useRoughnessFromMetallicTextureAlpha: boolean;
  64486. /**
  64487. * Specifies if the metallic texture contains the roughness information in its green channel.
  64488. */
  64489. useRoughnessFromMetallicTextureGreen: boolean;
  64490. /**
  64491. * Create a new ReflectivityBlock
  64492. * @param name defines the block name
  64493. */
  64494. constructor(name: string);
  64495. /**
  64496. * Initialize the block and prepare the context for build
  64497. * @param state defines the state that will be used for the build
  64498. */
  64499. initialize(state: NodeMaterialBuildState): void;
  64500. /**
  64501. * Gets the current class name
  64502. * @returns the class name
  64503. */
  64504. getClassName(): string;
  64505. /**
  64506. * Gets the metallic input component
  64507. */
  64508. get metallic(): NodeMaterialConnectionPoint;
  64509. /**
  64510. * Gets the roughness input component
  64511. */
  64512. get roughness(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the texture input component
  64515. */
  64516. get texture(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the reflectivity object output component
  64519. */
  64520. get reflectivity(): NodeMaterialConnectionPoint;
  64521. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64522. /**
  64523. * Gets the main code of the block (fragment side)
  64524. * @param state current state of the node material building
  64525. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64526. * @returns the shader code
  64527. */
  64528. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64530. protected _buildBlock(state: NodeMaterialBuildState): this;
  64531. protected _dumpPropertiesCode(): string;
  64532. serialize(): any;
  64533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64534. }
  64535. }
  64536. declare module BABYLON {
  64537. /**
  64538. * Block used to implement the anisotropy module of the PBR material
  64539. */
  64540. export class AnisotropyBlock extends NodeMaterialBlock {
  64541. /**
  64542. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64543. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64544. * It's less burden on the user side in the editor part.
  64545. */
  64546. /** @hidden */
  64547. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64548. /** @hidden */
  64549. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64550. /**
  64551. * Create a new AnisotropyBlock
  64552. * @param name defines the block name
  64553. */
  64554. constructor(name: string);
  64555. /**
  64556. * Initialize the block and prepare the context for build
  64557. * @param state defines the state that will be used for the build
  64558. */
  64559. initialize(state: NodeMaterialBuildState): void;
  64560. /**
  64561. * Gets the current class name
  64562. * @returns the class name
  64563. */
  64564. getClassName(): string;
  64565. /**
  64566. * Gets the intensity input component
  64567. */
  64568. get intensity(): NodeMaterialConnectionPoint;
  64569. /**
  64570. * Gets the direction input component
  64571. */
  64572. get direction(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the texture input component
  64575. */
  64576. get texture(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the uv input component
  64579. */
  64580. get uv(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the worldTangent input component
  64583. */
  64584. get worldTangent(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the anisotropy object output component
  64587. */
  64588. get anisotropy(): NodeMaterialConnectionPoint;
  64589. private _generateTBNSpace;
  64590. /**
  64591. * Gets the main code of the block (fragment side)
  64592. * @param state current state of the node material building
  64593. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64594. * @returns the shader code
  64595. */
  64596. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64598. protected _buildBlock(state: NodeMaterialBuildState): this;
  64599. }
  64600. }
  64601. declare module BABYLON {
  64602. /**
  64603. * Block used to implement the clear coat module of the PBR material
  64604. */
  64605. export class ClearCoatBlock extends NodeMaterialBlock {
  64606. private _scene;
  64607. /**
  64608. * Create a new ClearCoatBlock
  64609. * @param name defines the block name
  64610. */
  64611. constructor(name: string);
  64612. /**
  64613. * Initialize the block and prepare the context for build
  64614. * @param state defines the state that will be used for the build
  64615. */
  64616. initialize(state: NodeMaterialBuildState): void;
  64617. /**
  64618. * Gets the current class name
  64619. * @returns the class name
  64620. */
  64621. getClassName(): string;
  64622. /**
  64623. * Gets the intensity input component
  64624. */
  64625. get intensity(): NodeMaterialConnectionPoint;
  64626. /**
  64627. * Gets the roughness input component
  64628. */
  64629. get roughness(): NodeMaterialConnectionPoint;
  64630. /**
  64631. * Gets the ior input component
  64632. */
  64633. get ior(): NodeMaterialConnectionPoint;
  64634. /**
  64635. * Gets the texture input component
  64636. */
  64637. get texture(): NodeMaterialConnectionPoint;
  64638. /**
  64639. * Gets the bump texture input component
  64640. */
  64641. get bumpTexture(): NodeMaterialConnectionPoint;
  64642. /**
  64643. * Gets the uv input component
  64644. */
  64645. get uv(): NodeMaterialConnectionPoint;
  64646. /**
  64647. * Gets the tint color input component
  64648. */
  64649. get tintColor(): NodeMaterialConnectionPoint;
  64650. /**
  64651. * Gets the tint "at distance" input component
  64652. */
  64653. get tintAtDistance(): NodeMaterialConnectionPoint;
  64654. /**
  64655. * Gets the tint thickness input component
  64656. */
  64657. get tintThickness(): NodeMaterialConnectionPoint;
  64658. /**
  64659. * Gets the world tangent input component
  64660. */
  64661. get worldTangent(): NodeMaterialConnectionPoint;
  64662. /**
  64663. * Gets the clear coat object output component
  64664. */
  64665. get clearcoat(): NodeMaterialConnectionPoint;
  64666. autoConfigure(material: NodeMaterial): void;
  64667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64669. private _generateTBNSpace;
  64670. /**
  64671. * Gets the main code of the block (fragment side)
  64672. * @param state current state of the node material building
  64673. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64674. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64675. * @param worldPosVarName name of the variable holding the world position
  64676. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64677. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64678. * @param worldNormalVarName name of the variable holding the world normal
  64679. * @returns the shader code
  64680. */
  64681. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64682. protected _buildBlock(state: NodeMaterialBuildState): this;
  64683. }
  64684. }
  64685. declare module BABYLON {
  64686. /**
  64687. * Block used to implement the sub surface module of the PBR material
  64688. */
  64689. export class SubSurfaceBlock extends NodeMaterialBlock {
  64690. /**
  64691. * Create a new SubSurfaceBlock
  64692. * @param name defines the block name
  64693. */
  64694. constructor(name: string);
  64695. /**
  64696. * Stores the intensity of the different subsurface effects in the thickness texture.
  64697. * * the green channel is the translucency intensity.
  64698. * * the blue channel is the scattering intensity.
  64699. * * the alpha channel is the refraction intensity.
  64700. */
  64701. useMaskFromThicknessTexture: boolean;
  64702. /**
  64703. * Initialize the block and prepare the context for build
  64704. * @param state defines the state that will be used for the build
  64705. */
  64706. initialize(state: NodeMaterialBuildState): void;
  64707. /**
  64708. * Gets the current class name
  64709. * @returns the class name
  64710. */
  64711. getClassName(): string;
  64712. /**
  64713. * Gets the min thickness input component
  64714. */
  64715. get minThickness(): NodeMaterialConnectionPoint;
  64716. /**
  64717. * Gets the max thickness input component
  64718. */
  64719. get maxThickness(): NodeMaterialConnectionPoint;
  64720. /**
  64721. * Gets the thickness texture component
  64722. */
  64723. get thicknessTexture(): NodeMaterialConnectionPoint;
  64724. /**
  64725. * Gets the tint color input component
  64726. */
  64727. get tintColor(): NodeMaterialConnectionPoint;
  64728. /**
  64729. * Gets the translucency intensity input component
  64730. */
  64731. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the translucency diffusion distance input component
  64734. */
  64735. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the refraction object parameters
  64738. */
  64739. get refraction(): NodeMaterialConnectionPoint;
  64740. /**
  64741. * Gets the sub surface object output component
  64742. */
  64743. get subsurface(): NodeMaterialConnectionPoint;
  64744. autoConfigure(material: NodeMaterial): void;
  64745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64746. /**
  64747. * Gets the main code of the block (fragment side)
  64748. * @param state current state of the node material building
  64749. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64750. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64751. * @param worldPosVarName name of the variable holding the world position
  64752. * @returns the shader code
  64753. */
  64754. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64755. protected _buildBlock(state: NodeMaterialBuildState): this;
  64756. }
  64757. }
  64758. declare module BABYLON {
  64759. /**
  64760. * Block used to implement the PBR metallic/roughness model
  64761. */
  64762. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64763. /**
  64764. * Gets or sets the light associated with this block
  64765. */
  64766. light: Nullable<Light>;
  64767. private _lightId;
  64768. private _scene;
  64769. private _environmentBRDFTexture;
  64770. private _environmentBrdfSamplerName;
  64771. private _vNormalWName;
  64772. private _invertNormalName;
  64773. /**
  64774. * Create a new ReflectionBlock
  64775. * @param name defines the block name
  64776. */
  64777. constructor(name: string);
  64778. /**
  64779. * Intensity of the direct lights e.g. the four lights available in your scene.
  64780. * This impacts both the direct diffuse and specular highlights.
  64781. */
  64782. directIntensity: number;
  64783. /**
  64784. * Intensity of the environment e.g. how much the environment will light the object
  64785. * either through harmonics for rough material or through the refelction for shiny ones.
  64786. */
  64787. environmentIntensity: number;
  64788. /**
  64789. * This is a special control allowing the reduction of the specular highlights coming from the
  64790. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64791. */
  64792. specularIntensity: number;
  64793. /**
  64794. * Defines the falloff type used in this material.
  64795. * It by default is Physical.
  64796. */
  64797. lightFalloff: number;
  64798. /**
  64799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64800. */
  64801. useAlphaFromAlbedoTexture: boolean;
  64802. /**
  64803. * Specifies that alpha test should be used
  64804. */
  64805. useAlphaTest: boolean;
  64806. /**
  64807. * Defines the alpha limits in alpha test mode.
  64808. */
  64809. alphaTestCutoff: number;
  64810. /**
  64811. * Specifies that alpha blending should be used
  64812. */
  64813. useAlphaBlending: boolean;
  64814. /**
  64815. * Defines if the alpha value should be determined via the rgb values.
  64816. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64817. */
  64818. opacityRGB: boolean;
  64819. /**
  64820. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64821. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64822. */
  64823. useRadianceOverAlpha: boolean;
  64824. /**
  64825. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64826. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64827. */
  64828. useSpecularOverAlpha: boolean;
  64829. /**
  64830. * Enables specular anti aliasing in the PBR shader.
  64831. * It will both interacts on the Geometry for analytical and IBL lighting.
  64832. * It also prefilter the roughness map based on the bump values.
  64833. */
  64834. enableSpecularAntiAliasing: boolean;
  64835. /**
  64836. * Enables realtime filtering on the texture.
  64837. */
  64838. realTimeFiltering: boolean;
  64839. /**
  64840. * Quality switch for realtime filtering
  64841. */
  64842. realTimeFilteringQuality: number;
  64843. /**
  64844. * Defines if the material uses energy conservation.
  64845. */
  64846. useEnergyConservation: boolean;
  64847. /**
  64848. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64849. * too much the area relying on ambient texture to define their ambient occlusion.
  64850. */
  64851. useRadianceOcclusion: boolean;
  64852. /**
  64853. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64854. * makes the reflect vector face the model (under horizon).
  64855. */
  64856. useHorizonOcclusion: boolean;
  64857. /**
  64858. * If set to true, no lighting calculations will be applied.
  64859. */
  64860. unlit: boolean;
  64861. /**
  64862. * Force normal to face away from face.
  64863. */
  64864. forceNormalForward: boolean;
  64865. /**
  64866. * Defines the material debug mode.
  64867. * It helps seeing only some components of the material while troubleshooting.
  64868. */
  64869. debugMode: number;
  64870. /**
  64871. * Specify from where on screen the debug mode should start.
  64872. * The value goes from -1 (full screen) to 1 (not visible)
  64873. * It helps with side by side comparison against the final render
  64874. * This defaults to 0
  64875. */
  64876. debugLimit: number;
  64877. /**
  64878. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64879. * You can use the factor to better multiply the final value.
  64880. */
  64881. debugFactor: number;
  64882. /**
  64883. * Initialize the block and prepare the context for build
  64884. * @param state defines the state that will be used for the build
  64885. */
  64886. initialize(state: NodeMaterialBuildState): void;
  64887. /**
  64888. * Gets the current class name
  64889. * @returns the class name
  64890. */
  64891. getClassName(): string;
  64892. /**
  64893. * Gets the world position input component
  64894. */
  64895. get worldPosition(): NodeMaterialConnectionPoint;
  64896. /**
  64897. * Gets the world normal input component
  64898. */
  64899. get worldNormal(): NodeMaterialConnectionPoint;
  64900. /**
  64901. * Gets the perturbed normal input component
  64902. */
  64903. get perturbedNormal(): NodeMaterialConnectionPoint;
  64904. /**
  64905. * Gets the camera position input component
  64906. */
  64907. get cameraPosition(): NodeMaterialConnectionPoint;
  64908. /**
  64909. * Gets the base color input component
  64910. */
  64911. get baseColor(): NodeMaterialConnectionPoint;
  64912. /**
  64913. * Gets the opacity texture input component
  64914. */
  64915. get opacityTexture(): NodeMaterialConnectionPoint;
  64916. /**
  64917. * Gets the ambient color input component
  64918. */
  64919. get ambientColor(): NodeMaterialConnectionPoint;
  64920. /**
  64921. * Gets the reflectivity object parameters
  64922. */
  64923. get reflectivity(): NodeMaterialConnectionPoint;
  64924. /**
  64925. * Gets the ambient occlusion object parameters
  64926. */
  64927. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64928. /**
  64929. * Gets the reflection object parameters
  64930. */
  64931. get reflection(): NodeMaterialConnectionPoint;
  64932. /**
  64933. * Gets the sheen object parameters
  64934. */
  64935. get sheen(): NodeMaterialConnectionPoint;
  64936. /**
  64937. * Gets the clear coat object parameters
  64938. */
  64939. get clearcoat(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the sub surface object parameters
  64942. */
  64943. get subsurface(): NodeMaterialConnectionPoint;
  64944. /**
  64945. * Gets the anisotropy object parameters
  64946. */
  64947. get anisotropy(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the ambient output component
  64950. */
  64951. get ambient(): NodeMaterialConnectionPoint;
  64952. /**
  64953. * Gets the diffuse output component
  64954. */
  64955. get diffuse(): NodeMaterialConnectionPoint;
  64956. /**
  64957. * Gets the specular output component
  64958. */
  64959. get specular(): NodeMaterialConnectionPoint;
  64960. /**
  64961. * Gets the sheen output component
  64962. */
  64963. get sheenDir(): NodeMaterialConnectionPoint;
  64964. /**
  64965. * Gets the clear coat output component
  64966. */
  64967. get clearcoatDir(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the indirect diffuse output component
  64970. */
  64971. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64972. /**
  64973. * Gets the indirect specular output component
  64974. */
  64975. get specularIndirect(): NodeMaterialConnectionPoint;
  64976. /**
  64977. * Gets the indirect sheen output component
  64978. */
  64979. get sheenIndirect(): NodeMaterialConnectionPoint;
  64980. /**
  64981. * Gets the indirect clear coat output component
  64982. */
  64983. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64984. /**
  64985. * Gets the refraction output component
  64986. */
  64987. get refraction(): NodeMaterialConnectionPoint;
  64988. /**
  64989. * Gets the global lighting output component
  64990. */
  64991. get lighting(): NodeMaterialConnectionPoint;
  64992. /**
  64993. * Gets the shadow output component
  64994. */
  64995. get shadow(): NodeMaterialConnectionPoint;
  64996. /**
  64997. * Gets the alpha output component
  64998. */
  64999. get alpha(): NodeMaterialConnectionPoint;
  65000. autoConfigure(material: NodeMaterial): void;
  65001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65002. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65003. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65004. private _injectVertexCode;
  65005. /**
  65006. * Gets the code corresponding to the albedo/opacity module
  65007. * @returns the shader code
  65008. */
  65009. getAlbedoOpacityCode(): string;
  65010. protected _buildBlock(state: NodeMaterialBuildState): this;
  65011. protected _dumpPropertiesCode(): string;
  65012. serialize(): any;
  65013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65014. }
  65015. }
  65016. declare module BABYLON {
  65017. /**
  65018. * Block used to compute value of one parameter modulo another
  65019. */
  65020. export class ModBlock extends NodeMaterialBlock {
  65021. /**
  65022. * Creates a new ModBlock
  65023. * @param name defines the block name
  65024. */
  65025. constructor(name: string);
  65026. /**
  65027. * Gets the current class name
  65028. * @returns the class name
  65029. */
  65030. getClassName(): string;
  65031. /**
  65032. * Gets the left operand input component
  65033. */
  65034. get left(): NodeMaterialConnectionPoint;
  65035. /**
  65036. * Gets the right operand input component
  65037. */
  65038. get right(): NodeMaterialConnectionPoint;
  65039. /**
  65040. * Gets the output component
  65041. */
  65042. get output(): NodeMaterialConnectionPoint;
  65043. protected _buildBlock(state: NodeMaterialBuildState): this;
  65044. }
  65045. }
  65046. declare module BABYLON {
  65047. /**
  65048. * Configuration for Draco compression
  65049. */
  65050. export interface IDracoCompressionConfiguration {
  65051. /**
  65052. * Configuration for the decoder.
  65053. */
  65054. decoder: {
  65055. /**
  65056. * The url to the WebAssembly module.
  65057. */
  65058. wasmUrl?: string;
  65059. /**
  65060. * The url to the WebAssembly binary.
  65061. */
  65062. wasmBinaryUrl?: string;
  65063. /**
  65064. * The url to the fallback JavaScript module.
  65065. */
  65066. fallbackUrl?: string;
  65067. };
  65068. }
  65069. /**
  65070. * Draco compression (https://google.github.io/draco/)
  65071. *
  65072. * This class wraps the Draco module.
  65073. *
  65074. * **Encoder**
  65075. *
  65076. * The encoder is not currently implemented.
  65077. *
  65078. * **Decoder**
  65079. *
  65080. * 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.
  65081. *
  65082. * To update the configuration, use the following code:
  65083. * ```javascript
  65084. * DracoCompression.Configuration = {
  65085. * decoder: {
  65086. * wasmUrl: "<url to the WebAssembly library>",
  65087. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65088. * fallbackUrl: "<url to the fallback JavaScript library>",
  65089. * }
  65090. * };
  65091. * ```
  65092. *
  65093. * 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.
  65094. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65095. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65096. *
  65097. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65098. * ```javascript
  65099. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65100. * ```
  65101. *
  65102. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65103. */
  65104. export class DracoCompression implements IDisposable {
  65105. private _workerPoolPromise?;
  65106. private _decoderModulePromise?;
  65107. /**
  65108. * The configuration. Defaults to the following urls:
  65109. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65110. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65111. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65112. */
  65113. static Configuration: IDracoCompressionConfiguration;
  65114. /**
  65115. * Returns true if the decoder configuration is available.
  65116. */
  65117. static get DecoderAvailable(): boolean;
  65118. /**
  65119. * Default number of workers to create when creating the draco compression object.
  65120. */
  65121. static DefaultNumWorkers: number;
  65122. private static GetDefaultNumWorkers;
  65123. private static _Default;
  65124. /**
  65125. * Default instance for the draco compression object.
  65126. */
  65127. static get Default(): DracoCompression;
  65128. /**
  65129. * Constructor
  65130. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65131. */
  65132. constructor(numWorkers?: number);
  65133. /**
  65134. * Stop all async operations and release resources.
  65135. */
  65136. dispose(): void;
  65137. /**
  65138. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65139. * @returns a promise that resolves when ready
  65140. */
  65141. whenReadyAsync(): Promise<void>;
  65142. /**
  65143. * Decode Draco compressed mesh data to vertex data.
  65144. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65145. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65146. * @returns A promise that resolves with the decoded vertex data
  65147. */
  65148. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65149. [kind: string]: number;
  65150. }): Promise<VertexData>;
  65151. }
  65152. }
  65153. declare module BABYLON {
  65154. /**
  65155. * Class for building Constructive Solid Geometry
  65156. */
  65157. export class CSG {
  65158. private polygons;
  65159. /**
  65160. * The world matrix
  65161. */
  65162. matrix: Matrix;
  65163. /**
  65164. * Stores the position
  65165. */
  65166. position: Vector3;
  65167. /**
  65168. * Stores the rotation
  65169. */
  65170. rotation: Vector3;
  65171. /**
  65172. * Stores the rotation quaternion
  65173. */
  65174. rotationQuaternion: Nullable<Quaternion>;
  65175. /**
  65176. * Stores the scaling vector
  65177. */
  65178. scaling: Vector3;
  65179. /**
  65180. * Convert the Mesh to CSG
  65181. * @param mesh The Mesh to convert to CSG
  65182. * @returns A new CSG from the Mesh
  65183. */
  65184. static FromMesh(mesh: Mesh): CSG;
  65185. /**
  65186. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65187. * @param polygons Polygons used to construct a CSG solid
  65188. */
  65189. private static FromPolygons;
  65190. /**
  65191. * Clones, or makes a deep copy, of the CSG
  65192. * @returns A new CSG
  65193. */
  65194. clone(): CSG;
  65195. /**
  65196. * Unions this CSG with another CSG
  65197. * @param csg The CSG to union against this CSG
  65198. * @returns The unioned CSG
  65199. */
  65200. union(csg: CSG): CSG;
  65201. /**
  65202. * Unions this CSG with another CSG in place
  65203. * @param csg The CSG to union against this CSG
  65204. */
  65205. unionInPlace(csg: CSG): void;
  65206. /**
  65207. * Subtracts this CSG with another CSG
  65208. * @param csg The CSG to subtract against this CSG
  65209. * @returns A new CSG
  65210. */
  65211. subtract(csg: CSG): CSG;
  65212. /**
  65213. * Subtracts this CSG with another CSG in place
  65214. * @param csg The CSG to subtact against this CSG
  65215. */
  65216. subtractInPlace(csg: CSG): void;
  65217. /**
  65218. * Intersect this CSG with another CSG
  65219. * @param csg The CSG to intersect against this CSG
  65220. * @returns A new CSG
  65221. */
  65222. intersect(csg: CSG): CSG;
  65223. /**
  65224. * Intersects this CSG with another CSG in place
  65225. * @param csg The CSG to intersect against this CSG
  65226. */
  65227. intersectInPlace(csg: CSG): void;
  65228. /**
  65229. * Return a new CSG solid with solid and empty space switched. This solid is
  65230. * not modified.
  65231. * @returns A new CSG solid with solid and empty space switched
  65232. */
  65233. inverse(): CSG;
  65234. /**
  65235. * Inverses the CSG in place
  65236. */
  65237. inverseInPlace(): void;
  65238. /**
  65239. * This is used to keep meshes transformations so they can be restored
  65240. * when we build back a Babylon Mesh
  65241. * NB : All CSG operations are performed in world coordinates
  65242. * @param csg The CSG to copy the transform attributes from
  65243. * @returns This CSG
  65244. */
  65245. copyTransformAttributes(csg: CSG): CSG;
  65246. /**
  65247. * Build Raw mesh from CSG
  65248. * Coordinates here are in world space
  65249. * @param name The name of the mesh geometry
  65250. * @param scene The Scene
  65251. * @param keepSubMeshes Specifies if the submeshes should be kept
  65252. * @returns A new Mesh
  65253. */
  65254. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65255. /**
  65256. * Build Mesh from CSG taking material and transforms into account
  65257. * @param name The name of the Mesh
  65258. * @param material The material of the Mesh
  65259. * @param scene The Scene
  65260. * @param keepSubMeshes Specifies if submeshes should be kept
  65261. * @returns The new Mesh
  65262. */
  65263. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65264. }
  65265. }
  65266. declare module BABYLON {
  65267. /**
  65268. * Class used to create a trail following a mesh
  65269. */
  65270. export class TrailMesh extends Mesh {
  65271. private _generator;
  65272. private _autoStart;
  65273. private _running;
  65274. private _diameter;
  65275. private _length;
  65276. private _sectionPolygonPointsCount;
  65277. private _sectionVectors;
  65278. private _sectionNormalVectors;
  65279. private _beforeRenderObserver;
  65280. /**
  65281. * @constructor
  65282. * @param name The value used by scene.getMeshByName() to do a lookup.
  65283. * @param generator The mesh or transform node to generate a trail.
  65284. * @param scene The scene to add this mesh to.
  65285. * @param diameter Diameter of trailing mesh. Default is 1.
  65286. * @param length Length of trailing mesh. Default is 60.
  65287. * @param autoStart Automatically start trailing mesh. Default true.
  65288. */
  65289. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65290. /**
  65291. * "TrailMesh"
  65292. * @returns "TrailMesh"
  65293. */
  65294. getClassName(): string;
  65295. private _createMesh;
  65296. /**
  65297. * Start trailing mesh.
  65298. */
  65299. start(): void;
  65300. /**
  65301. * Stop trailing mesh.
  65302. */
  65303. stop(): void;
  65304. /**
  65305. * Update trailing mesh geometry.
  65306. */
  65307. update(): void;
  65308. /**
  65309. * Returns a new TrailMesh object.
  65310. * @param name is a string, the name given to the new mesh
  65311. * @param newGenerator use new generator object for cloned trail mesh
  65312. * @returns a new mesh
  65313. */
  65314. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65315. /**
  65316. * Serializes this trail mesh
  65317. * @param serializationObject object to write serialization to
  65318. */
  65319. serialize(serializationObject: any): void;
  65320. /**
  65321. * Parses a serialized trail mesh
  65322. * @param parsedMesh the serialized mesh
  65323. * @param scene the scene to create the trail mesh in
  65324. * @returns the created trail mesh
  65325. */
  65326. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65327. }
  65328. }
  65329. declare module BABYLON {
  65330. /**
  65331. * Class containing static functions to help procedurally build meshes
  65332. */
  65333. export class TiledBoxBuilder {
  65334. /**
  65335. * Creates a box mesh
  65336. * 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)
  65337. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65339. * * 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
  65340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65341. * @param name defines the name of the mesh
  65342. * @param options defines the options used to create the mesh
  65343. * @param scene defines the hosting scene
  65344. * @returns the box mesh
  65345. */
  65346. static CreateTiledBox(name: string, options: {
  65347. pattern?: number;
  65348. width?: number;
  65349. height?: number;
  65350. depth?: number;
  65351. tileSize?: number;
  65352. tileWidth?: number;
  65353. tileHeight?: number;
  65354. alignHorizontal?: number;
  65355. alignVertical?: number;
  65356. faceUV?: Vector4[];
  65357. faceColors?: Color4[];
  65358. sideOrientation?: number;
  65359. updatable?: boolean;
  65360. }, scene?: Nullable<Scene>): Mesh;
  65361. }
  65362. }
  65363. declare module BABYLON {
  65364. /**
  65365. * Class containing static functions to help procedurally build meshes
  65366. */
  65367. export class TorusKnotBuilder {
  65368. /**
  65369. * Creates a torus knot mesh
  65370. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65371. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65372. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65373. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65375. * * 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
  65376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65377. * @param name defines the name of the mesh
  65378. * @param options defines the options used to create the mesh
  65379. * @param scene defines the hosting scene
  65380. * @returns the torus knot mesh
  65381. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65382. */
  65383. static CreateTorusKnot(name: string, options: {
  65384. radius?: number;
  65385. tube?: number;
  65386. radialSegments?: number;
  65387. tubularSegments?: number;
  65388. p?: number;
  65389. q?: number;
  65390. updatable?: boolean;
  65391. sideOrientation?: number;
  65392. frontUVs?: Vector4;
  65393. backUVs?: Vector4;
  65394. }, scene: any): Mesh;
  65395. }
  65396. }
  65397. declare module BABYLON {
  65398. /**
  65399. * Polygon
  65400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65401. */
  65402. export class Polygon {
  65403. /**
  65404. * Creates a rectangle
  65405. * @param xmin bottom X coord
  65406. * @param ymin bottom Y coord
  65407. * @param xmax top X coord
  65408. * @param ymax top Y coord
  65409. * @returns points that make the resulting rectation
  65410. */
  65411. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65412. /**
  65413. * Creates a circle
  65414. * @param radius radius of circle
  65415. * @param cx scale in x
  65416. * @param cy scale in y
  65417. * @param numberOfSides number of sides that make up the circle
  65418. * @returns points that make the resulting circle
  65419. */
  65420. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65421. /**
  65422. * Creates a polygon from input string
  65423. * @param input Input polygon data
  65424. * @returns the parsed points
  65425. */
  65426. static Parse(input: string): Vector2[];
  65427. /**
  65428. * Starts building a polygon from x and y coordinates
  65429. * @param x x coordinate
  65430. * @param y y coordinate
  65431. * @returns the started path2
  65432. */
  65433. static StartingAt(x: number, y: number): Path2;
  65434. }
  65435. /**
  65436. * Builds a polygon
  65437. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65438. */
  65439. export class PolygonMeshBuilder {
  65440. private _points;
  65441. private _outlinepoints;
  65442. private _holes;
  65443. private _name;
  65444. private _scene;
  65445. private _epoints;
  65446. private _eholes;
  65447. private _addToepoint;
  65448. /**
  65449. * Babylon reference to the earcut plugin.
  65450. */
  65451. bjsEarcut: any;
  65452. /**
  65453. * Creates a PolygonMeshBuilder
  65454. * @param name name of the builder
  65455. * @param contours Path of the polygon
  65456. * @param scene scene to add to when creating the mesh
  65457. * @param earcutInjection can be used to inject your own earcut reference
  65458. */
  65459. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65460. /**
  65461. * Adds a whole within the polygon
  65462. * @param hole Array of points defining the hole
  65463. * @returns this
  65464. */
  65465. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65466. /**
  65467. * Creates the polygon
  65468. * @param updatable If the mesh should be updatable
  65469. * @param depth The depth of the mesh created
  65470. * @returns the created mesh
  65471. */
  65472. build(updatable?: boolean, depth?: number): Mesh;
  65473. /**
  65474. * Creates the polygon
  65475. * @param depth The depth of the mesh created
  65476. * @returns the created VertexData
  65477. */
  65478. buildVertexData(depth?: number): VertexData;
  65479. /**
  65480. * Adds a side to the polygon
  65481. * @param positions points that make the polygon
  65482. * @param normals normals of the polygon
  65483. * @param uvs uvs of the polygon
  65484. * @param indices indices of the polygon
  65485. * @param bounds bounds of the polygon
  65486. * @param points points of the polygon
  65487. * @param depth depth of the polygon
  65488. * @param flip flip of the polygon
  65489. */
  65490. private addSide;
  65491. }
  65492. }
  65493. declare module BABYLON {
  65494. /**
  65495. * Class containing static functions to help procedurally build meshes
  65496. */
  65497. export class PolygonBuilder {
  65498. /**
  65499. * Creates a polygon mesh
  65500. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65501. * * 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
  65502. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65504. * * 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)
  65505. * * Remember you can only change the shape positions, not their number when updating a polygon
  65506. * @param name defines the name of the mesh
  65507. * @param options defines the options used to create the mesh
  65508. * @param scene defines the hosting scene
  65509. * @param earcutInjection can be used to inject your own earcut reference
  65510. * @returns the polygon mesh
  65511. */
  65512. static CreatePolygon(name: string, options: {
  65513. shape: Vector3[];
  65514. holes?: Vector3[][];
  65515. depth?: number;
  65516. faceUV?: Vector4[];
  65517. faceColors?: Color4[];
  65518. updatable?: boolean;
  65519. sideOrientation?: number;
  65520. frontUVs?: Vector4;
  65521. backUVs?: Vector4;
  65522. wrap?: boolean;
  65523. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65524. /**
  65525. * Creates an extruded polygon mesh, with depth in the Y direction.
  65526. * * 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)
  65527. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65528. * @param name defines the name of the mesh
  65529. * @param options defines the options used to create the mesh
  65530. * @param scene defines the hosting scene
  65531. * @param earcutInjection can be used to inject your own earcut reference
  65532. * @returns the polygon mesh
  65533. */
  65534. static ExtrudePolygon(name: string, options: {
  65535. shape: Vector3[];
  65536. holes?: Vector3[][];
  65537. depth?: number;
  65538. faceUV?: Vector4[];
  65539. faceColors?: Color4[];
  65540. updatable?: boolean;
  65541. sideOrientation?: number;
  65542. frontUVs?: Vector4;
  65543. backUVs?: Vector4;
  65544. wrap?: boolean;
  65545. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65546. }
  65547. }
  65548. declare module BABYLON {
  65549. /**
  65550. * Class containing static functions to help procedurally build meshes
  65551. */
  65552. export class LatheBuilder {
  65553. /**
  65554. * Creates lathe mesh.
  65555. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65556. * * 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
  65557. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65558. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65559. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65560. * * 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
  65561. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65562. * * 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
  65563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65564. * * 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
  65565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65567. * @param name defines the name of the mesh
  65568. * @param options defines the options used to create the mesh
  65569. * @param scene defines the hosting scene
  65570. * @returns the lathe mesh
  65571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65572. */
  65573. static CreateLathe(name: string, options: {
  65574. shape: Vector3[];
  65575. radius?: number;
  65576. tessellation?: number;
  65577. clip?: number;
  65578. arc?: number;
  65579. closed?: boolean;
  65580. updatable?: boolean;
  65581. sideOrientation?: number;
  65582. frontUVs?: Vector4;
  65583. backUVs?: Vector4;
  65584. cap?: number;
  65585. invertUV?: boolean;
  65586. }, scene?: Nullable<Scene>): Mesh;
  65587. }
  65588. }
  65589. declare module BABYLON {
  65590. /**
  65591. * Class containing static functions to help procedurally build meshes
  65592. */
  65593. export class TiledPlaneBuilder {
  65594. /**
  65595. * Creates a tiled plane mesh
  65596. * * The parameter `pattern` will, depending on value, do nothing or
  65597. * * * flip (reflect about central vertical) alternate tiles across and up
  65598. * * * flip every tile on alternate rows
  65599. * * * rotate (180 degs) alternate tiles across and up
  65600. * * * rotate every tile on alternate rows
  65601. * * * flip and rotate alternate tiles across and up
  65602. * * * flip and rotate every tile on alternate rows
  65603. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65604. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65605. * * 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
  65606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65607. * * 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)
  65608. * * 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)
  65609. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65610. * @param name defines the name of the mesh
  65611. * @param options defines the options used to create the mesh
  65612. * @param scene defines the hosting scene
  65613. * @returns the box mesh
  65614. */
  65615. static CreateTiledPlane(name: string, options: {
  65616. pattern?: number;
  65617. tileSize?: number;
  65618. tileWidth?: number;
  65619. tileHeight?: number;
  65620. size?: number;
  65621. width?: number;
  65622. height?: number;
  65623. alignHorizontal?: number;
  65624. alignVertical?: number;
  65625. sideOrientation?: number;
  65626. frontUVs?: Vector4;
  65627. backUVs?: Vector4;
  65628. updatable?: boolean;
  65629. }, scene?: Nullable<Scene>): Mesh;
  65630. }
  65631. }
  65632. declare module BABYLON {
  65633. /**
  65634. * Class containing static functions to help procedurally build meshes
  65635. */
  65636. export class TubeBuilder {
  65637. /**
  65638. * Creates a tube mesh.
  65639. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65640. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65641. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65642. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65643. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65644. * * 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)
  65645. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65646. * * 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
  65647. * * 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
  65648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65649. * * 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
  65650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65652. * @param name defines the name of the mesh
  65653. * @param options defines the options used to create the mesh
  65654. * @param scene defines the hosting scene
  65655. * @returns the tube mesh
  65656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65657. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65658. */
  65659. static CreateTube(name: string, options: {
  65660. path: Vector3[];
  65661. radius?: number;
  65662. tessellation?: number;
  65663. radiusFunction?: {
  65664. (i: number, distance: number): number;
  65665. };
  65666. cap?: number;
  65667. arc?: number;
  65668. updatable?: boolean;
  65669. sideOrientation?: number;
  65670. frontUVs?: Vector4;
  65671. backUVs?: Vector4;
  65672. instance?: Mesh;
  65673. invertUV?: boolean;
  65674. }, scene?: Nullable<Scene>): Mesh;
  65675. }
  65676. }
  65677. declare module BABYLON {
  65678. /**
  65679. * Class containing static functions to help procedurally build meshes
  65680. */
  65681. export class IcoSphereBuilder {
  65682. /**
  65683. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65684. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65685. * * 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`)
  65686. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65687. * * 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
  65688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65689. * * 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
  65690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65691. * @param name defines the name of the mesh
  65692. * @param options defines the options used to create the mesh
  65693. * @param scene defines the hosting scene
  65694. * @returns the icosahedron mesh
  65695. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65696. */
  65697. static CreateIcoSphere(name: string, options: {
  65698. radius?: number;
  65699. radiusX?: number;
  65700. radiusY?: number;
  65701. radiusZ?: number;
  65702. flat?: boolean;
  65703. subdivisions?: number;
  65704. sideOrientation?: number;
  65705. frontUVs?: Vector4;
  65706. backUVs?: Vector4;
  65707. updatable?: boolean;
  65708. }, scene?: Nullable<Scene>): Mesh;
  65709. }
  65710. }
  65711. declare module BABYLON {
  65712. /**
  65713. * Class containing static functions to help procedurally build meshes
  65714. */
  65715. export class DecalBuilder {
  65716. /**
  65717. * Creates a decal mesh.
  65718. * 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
  65719. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65720. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65721. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65722. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65723. * @param name defines the name of the mesh
  65724. * @param sourceMesh defines the mesh where the decal must be applied
  65725. * @param options defines the options used to create the mesh
  65726. * @param scene defines the hosting scene
  65727. * @returns the decal mesh
  65728. * @see https://doc.babylonjs.com/how_to/decals
  65729. */
  65730. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65731. position?: Vector3;
  65732. normal?: Vector3;
  65733. size?: Vector3;
  65734. angle?: number;
  65735. }): Mesh;
  65736. }
  65737. }
  65738. declare module BABYLON {
  65739. /**
  65740. * Class containing static functions to help procedurally build meshes
  65741. */
  65742. export class MeshBuilder {
  65743. /**
  65744. * Creates a box mesh
  65745. * * The parameter `size` sets the size (float) of each box side (default 1)
  65746. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65747. * * 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)
  65748. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65750. * * 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
  65751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65752. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65753. * @param name defines the name of the mesh
  65754. * @param options defines the options used to create the mesh
  65755. * @param scene defines the hosting scene
  65756. * @returns the box mesh
  65757. */
  65758. static CreateBox(name: string, options: {
  65759. size?: number;
  65760. width?: number;
  65761. height?: number;
  65762. depth?: number;
  65763. faceUV?: Vector4[];
  65764. faceColors?: Color4[];
  65765. sideOrientation?: number;
  65766. frontUVs?: Vector4;
  65767. backUVs?: Vector4;
  65768. wrap?: boolean;
  65769. topBaseAt?: number;
  65770. bottomBaseAt?: number;
  65771. updatable?: boolean;
  65772. }, scene?: Nullable<Scene>): Mesh;
  65773. /**
  65774. * Creates a tiled box mesh
  65775. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65777. * @param name defines the name of the mesh
  65778. * @param options defines the options used to create the mesh
  65779. * @param scene defines the hosting scene
  65780. * @returns the tiled box mesh
  65781. */
  65782. static CreateTiledBox(name: string, options: {
  65783. pattern?: number;
  65784. size?: number;
  65785. width?: number;
  65786. height?: number;
  65787. depth: number;
  65788. tileSize?: number;
  65789. tileWidth?: number;
  65790. tileHeight?: number;
  65791. faceUV?: Vector4[];
  65792. faceColors?: Color4[];
  65793. alignHorizontal?: number;
  65794. alignVertical?: number;
  65795. sideOrientation?: number;
  65796. updatable?: boolean;
  65797. }, scene?: Nullable<Scene>): Mesh;
  65798. /**
  65799. * Creates a sphere mesh
  65800. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65801. * * 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`)
  65802. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65803. * * 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
  65804. * * 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)
  65805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65806. * * 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
  65807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65808. * @param name defines the name of the mesh
  65809. * @param options defines the options used to create the mesh
  65810. * @param scene defines the hosting scene
  65811. * @returns the sphere mesh
  65812. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65813. */
  65814. static CreateSphere(name: string, options: {
  65815. segments?: number;
  65816. diameter?: number;
  65817. diameterX?: number;
  65818. diameterY?: number;
  65819. diameterZ?: number;
  65820. arc?: number;
  65821. slice?: number;
  65822. sideOrientation?: number;
  65823. frontUVs?: Vector4;
  65824. backUVs?: Vector4;
  65825. updatable?: boolean;
  65826. }, scene?: Nullable<Scene>): Mesh;
  65827. /**
  65828. * Creates a plane polygonal mesh. By default, this is a disc
  65829. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65830. * * 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
  65831. * * 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
  65832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65833. * * 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
  65834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65835. * @param name defines the name of the mesh
  65836. * @param options defines the options used to create the mesh
  65837. * @param scene defines the hosting scene
  65838. * @returns the plane polygonal mesh
  65839. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65840. */
  65841. static CreateDisc(name: string, options: {
  65842. radius?: number;
  65843. tessellation?: number;
  65844. arc?: number;
  65845. updatable?: boolean;
  65846. sideOrientation?: number;
  65847. frontUVs?: Vector4;
  65848. backUVs?: Vector4;
  65849. }, scene?: Nullable<Scene>): Mesh;
  65850. /**
  65851. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65852. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65853. * * 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`)
  65854. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65855. * * 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
  65856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65857. * * 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
  65858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65859. * @param name defines the name of the mesh
  65860. * @param options defines the options used to create the mesh
  65861. * @param scene defines the hosting scene
  65862. * @returns the icosahedron mesh
  65863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65864. */
  65865. static CreateIcoSphere(name: string, options: {
  65866. radius?: number;
  65867. radiusX?: number;
  65868. radiusY?: number;
  65869. radiusZ?: number;
  65870. flat?: boolean;
  65871. subdivisions?: number;
  65872. sideOrientation?: number;
  65873. frontUVs?: Vector4;
  65874. backUVs?: Vector4;
  65875. updatable?: boolean;
  65876. }, scene?: Nullable<Scene>): Mesh;
  65877. /**
  65878. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65879. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65880. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65881. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65882. * * 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
  65883. * * 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
  65884. * * 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
  65885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65886. * * 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
  65887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65888. * * 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
  65889. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65890. * * 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
  65891. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65893. * @param name defines the name of the mesh
  65894. * @param options defines the options used to create the mesh
  65895. * @param scene defines the hosting scene
  65896. * @returns the ribbon mesh
  65897. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65899. */
  65900. static CreateRibbon(name: string, options: {
  65901. pathArray: Vector3[][];
  65902. closeArray?: boolean;
  65903. closePath?: boolean;
  65904. offset?: number;
  65905. updatable?: boolean;
  65906. sideOrientation?: number;
  65907. frontUVs?: Vector4;
  65908. backUVs?: Vector4;
  65909. instance?: Mesh;
  65910. invertUV?: boolean;
  65911. uvs?: Vector2[];
  65912. colors?: Color4[];
  65913. }, scene?: Nullable<Scene>): Mesh;
  65914. /**
  65915. * Creates a cylinder or a cone mesh
  65916. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65917. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65918. * * 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.
  65919. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65920. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65921. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65922. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65923. * * 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).
  65924. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65925. * * 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).
  65926. * * 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
  65927. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65928. * * 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
  65929. * * 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.
  65930. * * If `enclose` is false, a ring surface is one element.
  65931. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65932. * * 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
  65933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65934. * * 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
  65935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65936. * @param name defines the name of the mesh
  65937. * @param options defines the options used to create the mesh
  65938. * @param scene defines the hosting scene
  65939. * @returns the cylinder mesh
  65940. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65941. */
  65942. static CreateCylinder(name: string, options: {
  65943. height?: number;
  65944. diameterTop?: number;
  65945. diameterBottom?: number;
  65946. diameter?: number;
  65947. tessellation?: number;
  65948. subdivisions?: number;
  65949. arc?: number;
  65950. faceColors?: Color4[];
  65951. faceUV?: Vector4[];
  65952. updatable?: boolean;
  65953. hasRings?: boolean;
  65954. enclose?: boolean;
  65955. cap?: number;
  65956. sideOrientation?: number;
  65957. frontUVs?: Vector4;
  65958. backUVs?: Vector4;
  65959. }, scene?: Nullable<Scene>): Mesh;
  65960. /**
  65961. * Creates a torus mesh
  65962. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65963. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65964. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65966. * * 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
  65967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65968. * @param name defines the name of the mesh
  65969. * @param options defines the options used to create the mesh
  65970. * @param scene defines the hosting scene
  65971. * @returns the torus mesh
  65972. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65973. */
  65974. static CreateTorus(name: string, options: {
  65975. diameter?: number;
  65976. thickness?: number;
  65977. tessellation?: number;
  65978. updatable?: boolean;
  65979. sideOrientation?: number;
  65980. frontUVs?: Vector4;
  65981. backUVs?: Vector4;
  65982. }, scene?: Nullable<Scene>): Mesh;
  65983. /**
  65984. * Creates a torus knot mesh
  65985. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65986. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65987. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65988. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65990. * * 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
  65991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65992. * @param name defines the name of the mesh
  65993. * @param options defines the options used to create the mesh
  65994. * @param scene defines the hosting scene
  65995. * @returns the torus knot mesh
  65996. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65997. */
  65998. static CreateTorusKnot(name: string, options: {
  65999. radius?: number;
  66000. tube?: number;
  66001. radialSegments?: number;
  66002. tubularSegments?: number;
  66003. p?: number;
  66004. q?: number;
  66005. updatable?: boolean;
  66006. sideOrientation?: number;
  66007. frontUVs?: Vector4;
  66008. backUVs?: Vector4;
  66009. }, scene?: Nullable<Scene>): Mesh;
  66010. /**
  66011. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66012. * * 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
  66013. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66014. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66015. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66016. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66017. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66018. * * 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
  66019. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66022. * @param name defines the name of the new line system
  66023. * @param options defines the options used to create the line system
  66024. * @param scene defines the hosting scene
  66025. * @returns a new line system mesh
  66026. */
  66027. static CreateLineSystem(name: string, options: {
  66028. lines: Vector3[][];
  66029. updatable?: boolean;
  66030. instance?: Nullable<LinesMesh>;
  66031. colors?: Nullable<Color4[][]>;
  66032. useVertexAlpha?: boolean;
  66033. }, scene: Nullable<Scene>): LinesMesh;
  66034. /**
  66035. * Creates a line mesh
  66036. * 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
  66037. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66038. * * The parameter `points` is an array successive Vector3
  66039. * * 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
  66040. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66041. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66042. * * When updating an instance, remember that only point positions can change, not the number of points
  66043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66045. * @param name defines the name of the new line system
  66046. * @param options defines the options used to create the line system
  66047. * @param scene defines the hosting scene
  66048. * @returns a new line mesh
  66049. */
  66050. static CreateLines(name: string, options: {
  66051. points: Vector3[];
  66052. updatable?: boolean;
  66053. instance?: Nullable<LinesMesh>;
  66054. colors?: Color4[];
  66055. useVertexAlpha?: boolean;
  66056. }, scene?: Nullable<Scene>): LinesMesh;
  66057. /**
  66058. * Creates a dashed line mesh
  66059. * * 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
  66060. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66061. * * The parameter `points` is an array successive Vector3
  66062. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66063. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66064. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66065. * * 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
  66066. * * When updating an instance, remember that only point positions can change, not the number of points
  66067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66068. * @param name defines the name of the mesh
  66069. * @param options defines the options used to create the mesh
  66070. * @param scene defines the hosting scene
  66071. * @returns the dashed line mesh
  66072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66073. */
  66074. static CreateDashedLines(name: string, options: {
  66075. points: Vector3[];
  66076. dashSize?: number;
  66077. gapSize?: number;
  66078. dashNb?: number;
  66079. updatable?: boolean;
  66080. instance?: LinesMesh;
  66081. }, scene?: Nullable<Scene>): LinesMesh;
  66082. /**
  66083. * 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.
  66084. * * 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.
  66085. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66086. * * 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.
  66087. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66088. * * 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
  66089. * * 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
  66090. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66092. * * 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
  66093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66095. * @param name defines the name of the mesh
  66096. * @param options defines the options used to create the mesh
  66097. * @param scene defines the hosting scene
  66098. * @returns the extruded shape mesh
  66099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66101. */
  66102. static ExtrudeShape(name: string, options: {
  66103. shape: Vector3[];
  66104. path: Vector3[];
  66105. scale?: number;
  66106. rotation?: number;
  66107. cap?: number;
  66108. updatable?: boolean;
  66109. sideOrientation?: number;
  66110. frontUVs?: Vector4;
  66111. backUVs?: Vector4;
  66112. instance?: Mesh;
  66113. invertUV?: boolean;
  66114. }, scene?: Nullable<Scene>): Mesh;
  66115. /**
  66116. * Creates an custom extruded shape mesh.
  66117. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66118. * * 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.
  66119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66120. * * 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
  66121. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66122. * * 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
  66123. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66124. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66125. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66126. * * 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
  66127. * * 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
  66128. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66130. * * 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
  66131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66133. * @param name defines the name of the mesh
  66134. * @param options defines the options used to create the mesh
  66135. * @param scene defines the hosting scene
  66136. * @returns the custom extruded shape mesh
  66137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66140. */
  66141. static ExtrudeShapeCustom(name: string, options: {
  66142. shape: Vector3[];
  66143. path: Vector3[];
  66144. scaleFunction?: any;
  66145. rotationFunction?: any;
  66146. ribbonCloseArray?: boolean;
  66147. ribbonClosePath?: boolean;
  66148. cap?: number;
  66149. updatable?: boolean;
  66150. sideOrientation?: number;
  66151. frontUVs?: Vector4;
  66152. backUVs?: Vector4;
  66153. instance?: Mesh;
  66154. invertUV?: boolean;
  66155. }, scene?: Nullable<Scene>): Mesh;
  66156. /**
  66157. * Creates lathe mesh.
  66158. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66159. * * 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
  66160. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66161. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66162. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66163. * * 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
  66164. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66165. * * 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
  66166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66167. * * 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
  66168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66170. * @param name defines the name of the mesh
  66171. * @param options defines the options used to create the mesh
  66172. * @param scene defines the hosting scene
  66173. * @returns the lathe mesh
  66174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66175. */
  66176. static CreateLathe(name: string, options: {
  66177. shape: Vector3[];
  66178. radius?: number;
  66179. tessellation?: number;
  66180. clip?: number;
  66181. arc?: number;
  66182. closed?: boolean;
  66183. updatable?: boolean;
  66184. sideOrientation?: number;
  66185. frontUVs?: Vector4;
  66186. backUVs?: Vector4;
  66187. cap?: number;
  66188. invertUV?: boolean;
  66189. }, scene?: Nullable<Scene>): Mesh;
  66190. /**
  66191. * Creates a tiled plane mesh
  66192. * * You can set a limited pattern arrangement with the tiles
  66193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66194. * * 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
  66195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66196. * @param name defines the name of the mesh
  66197. * @param options defines the options used to create the mesh
  66198. * @param scene defines the hosting scene
  66199. * @returns the plane mesh
  66200. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66201. */
  66202. static CreateTiledPlane(name: string, options: {
  66203. pattern?: number;
  66204. tileSize?: number;
  66205. tileWidth?: number;
  66206. tileHeight?: number;
  66207. size?: number;
  66208. width?: number;
  66209. height?: number;
  66210. alignHorizontal?: number;
  66211. alignVertical?: number;
  66212. sideOrientation?: number;
  66213. frontUVs?: Vector4;
  66214. backUVs?: Vector4;
  66215. updatable?: boolean;
  66216. }, scene?: Nullable<Scene>): Mesh;
  66217. /**
  66218. * Creates a plane mesh
  66219. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66220. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66221. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66223. * * 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
  66224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66225. * @param name defines the name of the mesh
  66226. * @param options defines the options used to create the mesh
  66227. * @param scene defines the hosting scene
  66228. * @returns the plane mesh
  66229. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66230. */
  66231. static CreatePlane(name: string, options: {
  66232. size?: number;
  66233. width?: number;
  66234. height?: number;
  66235. sideOrientation?: number;
  66236. frontUVs?: Vector4;
  66237. backUVs?: Vector4;
  66238. updatable?: boolean;
  66239. sourcePlane?: Plane;
  66240. }, scene?: Nullable<Scene>): Mesh;
  66241. /**
  66242. * Creates a ground mesh
  66243. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66244. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66246. * @param name defines the name of the mesh
  66247. * @param options defines the options used to create the mesh
  66248. * @param scene defines the hosting scene
  66249. * @returns the ground mesh
  66250. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66251. */
  66252. static CreateGround(name: string, options: {
  66253. width?: number;
  66254. height?: number;
  66255. subdivisions?: number;
  66256. subdivisionsX?: number;
  66257. subdivisionsY?: number;
  66258. updatable?: boolean;
  66259. }, scene?: Nullable<Scene>): Mesh;
  66260. /**
  66261. * Creates a tiled ground mesh
  66262. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66263. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66264. * * 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
  66265. * * 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
  66266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66267. * @param name defines the name of the mesh
  66268. * @param options defines the options used to create the mesh
  66269. * @param scene defines the hosting scene
  66270. * @returns the tiled ground mesh
  66271. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66272. */
  66273. static CreateTiledGround(name: string, options: {
  66274. xmin: number;
  66275. zmin: number;
  66276. xmax: number;
  66277. zmax: number;
  66278. subdivisions?: {
  66279. w: number;
  66280. h: number;
  66281. };
  66282. precision?: {
  66283. w: number;
  66284. h: number;
  66285. };
  66286. updatable?: boolean;
  66287. }, scene?: Nullable<Scene>): Mesh;
  66288. /**
  66289. * Creates a ground mesh from a height map
  66290. * * The parameter `url` sets the URL of the height map image resource.
  66291. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66292. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66293. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66294. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66295. * * 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.
  66296. * * 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).
  66297. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66299. * @param name defines the name of the mesh
  66300. * @param url defines the url to the height map
  66301. * @param options defines the options used to create the mesh
  66302. * @param scene defines the hosting scene
  66303. * @returns the ground mesh
  66304. * @see https://doc.babylonjs.com/babylon101/height_map
  66305. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66306. */
  66307. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66308. width?: number;
  66309. height?: number;
  66310. subdivisions?: number;
  66311. minHeight?: number;
  66312. maxHeight?: number;
  66313. colorFilter?: Color3;
  66314. alphaFilter?: number;
  66315. updatable?: boolean;
  66316. onReady?: (mesh: GroundMesh) => void;
  66317. }, scene?: Nullable<Scene>): GroundMesh;
  66318. /**
  66319. * Creates a polygon mesh
  66320. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66321. * * 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
  66322. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66324. * * 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)
  66325. * * Remember you can only change the shape positions, not their number when updating a polygon
  66326. * @param name defines the name of the mesh
  66327. * @param options defines the options used to create the mesh
  66328. * @param scene defines the hosting scene
  66329. * @param earcutInjection can be used to inject your own earcut reference
  66330. * @returns the polygon mesh
  66331. */
  66332. static CreatePolygon(name: string, options: {
  66333. shape: Vector3[];
  66334. holes?: Vector3[][];
  66335. depth?: number;
  66336. faceUV?: Vector4[];
  66337. faceColors?: Color4[];
  66338. updatable?: boolean;
  66339. sideOrientation?: number;
  66340. frontUVs?: Vector4;
  66341. backUVs?: Vector4;
  66342. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66343. /**
  66344. * Creates an extruded polygon mesh, with depth in the Y direction.
  66345. * * 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)
  66346. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66347. * @param name defines the name of the mesh
  66348. * @param options defines the options used to create the mesh
  66349. * @param scene defines the hosting scene
  66350. * @param earcutInjection can be used to inject your own earcut reference
  66351. * @returns the polygon mesh
  66352. */
  66353. static ExtrudePolygon(name: string, options: {
  66354. shape: Vector3[];
  66355. holes?: Vector3[][];
  66356. depth?: number;
  66357. faceUV?: Vector4[];
  66358. faceColors?: Color4[];
  66359. updatable?: boolean;
  66360. sideOrientation?: number;
  66361. frontUVs?: Vector4;
  66362. backUVs?: Vector4;
  66363. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66364. /**
  66365. * Creates a tube mesh.
  66366. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66367. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66368. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66369. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66370. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66371. * * 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)
  66372. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66373. * * 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
  66374. * * 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
  66375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66376. * * 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
  66377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66379. * @param name defines the name of the mesh
  66380. * @param options defines the options used to create the mesh
  66381. * @param scene defines the hosting scene
  66382. * @returns the tube mesh
  66383. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66384. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66385. */
  66386. static CreateTube(name: string, options: {
  66387. path: Vector3[];
  66388. radius?: number;
  66389. tessellation?: number;
  66390. radiusFunction?: {
  66391. (i: number, distance: number): number;
  66392. };
  66393. cap?: number;
  66394. arc?: number;
  66395. updatable?: boolean;
  66396. sideOrientation?: number;
  66397. frontUVs?: Vector4;
  66398. backUVs?: Vector4;
  66399. instance?: Mesh;
  66400. invertUV?: boolean;
  66401. }, scene?: Nullable<Scene>): Mesh;
  66402. /**
  66403. * Creates a polyhedron mesh
  66404. * * 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
  66405. * * The parameter `size` (positive float, default 1) sets the polygon size
  66406. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66407. * * 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`
  66408. * * 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
  66409. * * 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)`)
  66410. * * 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
  66411. * * 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
  66412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66413. * * 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
  66414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66415. * @param name defines the name of the mesh
  66416. * @param options defines the options used to create the mesh
  66417. * @param scene defines the hosting scene
  66418. * @returns the polyhedron mesh
  66419. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66420. */
  66421. static CreatePolyhedron(name: string, options: {
  66422. type?: number;
  66423. size?: number;
  66424. sizeX?: number;
  66425. sizeY?: number;
  66426. sizeZ?: number;
  66427. custom?: any;
  66428. faceUV?: Vector4[];
  66429. faceColors?: Color4[];
  66430. flat?: boolean;
  66431. updatable?: boolean;
  66432. sideOrientation?: number;
  66433. frontUVs?: Vector4;
  66434. backUVs?: Vector4;
  66435. }, scene?: Nullable<Scene>): Mesh;
  66436. /**
  66437. * Creates a decal mesh.
  66438. * 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
  66439. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66440. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66441. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66442. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66443. * @param name defines the name of the mesh
  66444. * @param sourceMesh defines the mesh where the decal must be applied
  66445. * @param options defines the options used to create the mesh
  66446. * @param scene defines the hosting scene
  66447. * @returns the decal mesh
  66448. * @see https://doc.babylonjs.com/how_to/decals
  66449. */
  66450. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66451. position?: Vector3;
  66452. normal?: Vector3;
  66453. size?: Vector3;
  66454. angle?: number;
  66455. }): Mesh;
  66456. }
  66457. }
  66458. declare module BABYLON {
  66459. /**
  66460. * A simplifier interface for future simplification implementations
  66461. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66462. */
  66463. export interface ISimplifier {
  66464. /**
  66465. * Simplification of a given mesh according to the given settings.
  66466. * Since this requires computation, it is assumed that the function runs async.
  66467. * @param settings The settings of the simplification, including quality and distance
  66468. * @param successCallback A callback that will be called after the mesh was simplified.
  66469. * @param errorCallback in case of an error, this callback will be called. optional.
  66470. */
  66471. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66472. }
  66473. /**
  66474. * Expected simplification settings.
  66475. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66476. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66477. */
  66478. export interface ISimplificationSettings {
  66479. /**
  66480. * Gets or sets the expected quality
  66481. */
  66482. quality: number;
  66483. /**
  66484. * Gets or sets the distance when this optimized version should be used
  66485. */
  66486. distance: number;
  66487. /**
  66488. * Gets an already optimized mesh
  66489. */
  66490. optimizeMesh?: boolean;
  66491. }
  66492. /**
  66493. * Class used to specify simplification options
  66494. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66495. */
  66496. export class SimplificationSettings implements ISimplificationSettings {
  66497. /** expected quality */
  66498. quality: number;
  66499. /** distance when this optimized version should be used */
  66500. distance: number;
  66501. /** already optimized mesh */
  66502. optimizeMesh?: boolean | undefined;
  66503. /**
  66504. * Creates a SimplificationSettings
  66505. * @param quality expected quality
  66506. * @param distance distance when this optimized version should be used
  66507. * @param optimizeMesh already optimized mesh
  66508. */
  66509. constructor(
  66510. /** expected quality */
  66511. quality: number,
  66512. /** distance when this optimized version should be used */
  66513. distance: number,
  66514. /** already optimized mesh */
  66515. optimizeMesh?: boolean | undefined);
  66516. }
  66517. /**
  66518. * Interface used to define a simplification task
  66519. */
  66520. export interface ISimplificationTask {
  66521. /**
  66522. * Array of settings
  66523. */
  66524. settings: Array<ISimplificationSettings>;
  66525. /**
  66526. * Simplification type
  66527. */
  66528. simplificationType: SimplificationType;
  66529. /**
  66530. * Mesh to simplify
  66531. */
  66532. mesh: Mesh;
  66533. /**
  66534. * Callback called on success
  66535. */
  66536. successCallback?: () => void;
  66537. /**
  66538. * Defines if parallel processing can be used
  66539. */
  66540. parallelProcessing: boolean;
  66541. }
  66542. /**
  66543. * Queue used to order the simplification tasks
  66544. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66545. */
  66546. export class SimplificationQueue {
  66547. private _simplificationArray;
  66548. /**
  66549. * Gets a boolean indicating that the process is still running
  66550. */
  66551. running: boolean;
  66552. /**
  66553. * Creates a new queue
  66554. */
  66555. constructor();
  66556. /**
  66557. * Adds a new simplification task
  66558. * @param task defines a task to add
  66559. */
  66560. addTask(task: ISimplificationTask): void;
  66561. /**
  66562. * Execute next task
  66563. */
  66564. executeNext(): void;
  66565. /**
  66566. * Execute a simplification task
  66567. * @param task defines the task to run
  66568. */
  66569. runSimplification(task: ISimplificationTask): void;
  66570. private getSimplifier;
  66571. }
  66572. /**
  66573. * The implemented types of simplification
  66574. * At the moment only Quadratic Error Decimation is implemented
  66575. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66576. */
  66577. export enum SimplificationType {
  66578. /** Quadratic error decimation */
  66579. QUADRATIC = 0
  66580. }
  66581. /**
  66582. * An implementation of the Quadratic Error simplification algorithm.
  66583. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66584. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66585. * @author RaananW
  66586. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66587. */
  66588. export class QuadraticErrorSimplification implements ISimplifier {
  66589. private _mesh;
  66590. private triangles;
  66591. private vertices;
  66592. private references;
  66593. private _reconstructedMesh;
  66594. /** Gets or sets the number pf sync interations */
  66595. syncIterations: number;
  66596. /** Gets or sets the aggressiveness of the simplifier */
  66597. aggressiveness: number;
  66598. /** Gets or sets the number of allowed iterations for decimation */
  66599. decimationIterations: number;
  66600. /** Gets or sets the espilon to use for bounding box computation */
  66601. boundingBoxEpsilon: number;
  66602. /**
  66603. * Creates a new QuadraticErrorSimplification
  66604. * @param _mesh defines the target mesh
  66605. */
  66606. constructor(_mesh: Mesh);
  66607. /**
  66608. * Simplification of a given mesh according to the given settings.
  66609. * Since this requires computation, it is assumed that the function runs async.
  66610. * @param settings The settings of the simplification, including quality and distance
  66611. * @param successCallback A callback that will be called after the mesh was simplified.
  66612. */
  66613. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66614. private runDecimation;
  66615. private initWithMesh;
  66616. private init;
  66617. private reconstructMesh;
  66618. private initDecimatedMesh;
  66619. private isFlipped;
  66620. private updateTriangles;
  66621. private identifyBorder;
  66622. private updateMesh;
  66623. private vertexError;
  66624. private calculateError;
  66625. }
  66626. }
  66627. declare module BABYLON {
  66628. interface Scene {
  66629. /** @hidden (Backing field) */
  66630. _simplificationQueue: SimplificationQueue;
  66631. /**
  66632. * Gets or sets the simplification queue attached to the scene
  66633. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66634. */
  66635. simplificationQueue: SimplificationQueue;
  66636. }
  66637. interface Mesh {
  66638. /**
  66639. * Simplify the mesh according to the given array of settings.
  66640. * Function will return immediately and will simplify async
  66641. * @param settings a collection of simplification settings
  66642. * @param parallelProcessing should all levels calculate parallel or one after the other
  66643. * @param simplificationType the type of simplification to run
  66644. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66645. * @returns the current mesh
  66646. */
  66647. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66648. }
  66649. /**
  66650. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66651. * created in a scene
  66652. */
  66653. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66654. /**
  66655. * The component name helpfull to identify the component in the list of scene components.
  66656. */
  66657. readonly name: string;
  66658. /**
  66659. * The scene the component belongs to.
  66660. */
  66661. scene: Scene;
  66662. /**
  66663. * Creates a new instance of the component for the given scene
  66664. * @param scene Defines the scene to register the component in
  66665. */
  66666. constructor(scene: Scene);
  66667. /**
  66668. * Registers the component in a given scene
  66669. */
  66670. register(): void;
  66671. /**
  66672. * Rebuilds the elements related to this component in case of
  66673. * context lost for instance.
  66674. */
  66675. rebuild(): void;
  66676. /**
  66677. * Disposes the component and the associated ressources
  66678. */
  66679. dispose(): void;
  66680. private _beforeCameraUpdate;
  66681. }
  66682. }
  66683. declare module BABYLON {
  66684. interface Mesh {
  66685. /**
  66686. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66687. */
  66688. thinInstanceEnablePicking: boolean;
  66689. /**
  66690. * Creates a new thin instance
  66691. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66692. * @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
  66693. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66694. */
  66695. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66696. /**
  66697. * Adds the transformation (matrix) of the current mesh as a thin instance
  66698. * @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
  66699. * @returns the thin instance index number
  66700. */
  66701. thinInstanceAddSelf(refresh: boolean): number;
  66702. /**
  66703. * Registers a custom attribute to be used with thin instances
  66704. * @param kind name of the attribute
  66705. * @param stride size in floats of the attribute
  66706. */
  66707. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66708. /**
  66709. * Sets the matrix of a thin instance
  66710. * @param index index of the thin instance
  66711. * @param matrix matrix to set
  66712. * @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
  66713. */
  66714. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66715. /**
  66716. * Sets the value of a custom attribute for a thin instance
  66717. * @param kind name of the attribute
  66718. * @param index index of the thin instance
  66719. * @param value value to set
  66720. * @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
  66721. */
  66722. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66723. /**
  66724. * 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.
  66725. */
  66726. thinInstanceCount: number;
  66727. /**
  66728. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66729. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66730. * @param buffer buffer to set
  66731. * @param stride size in floats of each value of the buffer
  66732. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66733. */
  66734. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66735. /**
  66736. * Gets the list of world matrices
  66737. * @return an array containing all the world matrices from the thin instances
  66738. */
  66739. thinInstanceGetWorldMatrices(): Matrix[];
  66740. /**
  66741. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66742. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66743. */
  66744. thinInstanceBufferUpdated(kind: string): void;
  66745. /**
  66746. * Applies a partial update to a buffer directly on the GPU
  66747. * 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
  66748. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66749. * @param data the data to set in the GPU buffer
  66750. * @param offset the offset in the GPU buffer where to update the data
  66751. */
  66752. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66753. /**
  66754. * Refreshes the bounding info, taking into account all the thin instances defined
  66755. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66756. */
  66757. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66758. /** @hidden */
  66759. _thinInstanceInitializeUserStorage(): void;
  66760. /** @hidden */
  66761. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66762. /** @hidden */
  66763. _userThinInstanceBuffersStorage: {
  66764. data: {
  66765. [key: string]: Float32Array;
  66766. };
  66767. sizes: {
  66768. [key: string]: number;
  66769. };
  66770. vertexBuffers: {
  66771. [key: string]: Nullable<VertexBuffer>;
  66772. };
  66773. strides: {
  66774. [key: string]: number;
  66775. };
  66776. };
  66777. }
  66778. }
  66779. declare module BABYLON {
  66780. /**
  66781. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66782. */
  66783. export interface INavigationEnginePlugin {
  66784. /**
  66785. * plugin name
  66786. */
  66787. name: string;
  66788. /**
  66789. * Creates a navigation mesh
  66790. * @param meshes array of all the geometry used to compute the navigatio mesh
  66791. * @param parameters bunch of parameters used to filter geometry
  66792. */
  66793. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66794. /**
  66795. * Create a navigation mesh debug mesh
  66796. * @param scene is where the mesh will be added
  66797. * @returns debug display mesh
  66798. */
  66799. createDebugNavMesh(scene: Scene): Mesh;
  66800. /**
  66801. * Get a navigation mesh constrained position, closest to the parameter position
  66802. * @param position world position
  66803. * @returns the closest point to position constrained by the navigation mesh
  66804. */
  66805. getClosestPoint(position: Vector3): Vector3;
  66806. /**
  66807. * Get a navigation mesh constrained position, closest to the parameter position
  66808. * @param position world position
  66809. * @param result output the closest point to position constrained by the navigation mesh
  66810. */
  66811. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66812. /**
  66813. * Get a navigation mesh constrained position, within a particular radius
  66814. * @param position world position
  66815. * @param maxRadius the maximum distance to the constrained world position
  66816. * @returns the closest point to position constrained by the navigation mesh
  66817. */
  66818. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66819. /**
  66820. * Get a navigation mesh constrained position, within a particular radius
  66821. * @param position world position
  66822. * @param maxRadius the maximum distance to the constrained world position
  66823. * @param result output the closest point to position constrained by the navigation mesh
  66824. */
  66825. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66826. /**
  66827. * Compute the final position from a segment made of destination-position
  66828. * @param position world position
  66829. * @param destination world position
  66830. * @returns the resulting point along the navmesh
  66831. */
  66832. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66833. /**
  66834. * Compute the final position from a segment made of destination-position
  66835. * @param position world position
  66836. * @param destination world position
  66837. * @param result output the resulting point along the navmesh
  66838. */
  66839. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66840. /**
  66841. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66842. * @param start world position
  66843. * @param end world position
  66844. * @returns array containing world position composing the path
  66845. */
  66846. computePath(start: Vector3, end: Vector3): Vector3[];
  66847. /**
  66848. * If this plugin is supported
  66849. * @returns true if plugin is supported
  66850. */
  66851. isSupported(): boolean;
  66852. /**
  66853. * Create a new Crowd so you can add agents
  66854. * @param maxAgents the maximum agent count in the crowd
  66855. * @param maxAgentRadius the maximum radius an agent can have
  66856. * @param scene to attach the crowd to
  66857. * @returns the crowd you can add agents to
  66858. */
  66859. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66860. /**
  66861. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66862. * The queries will try to find a solution within those bounds
  66863. * default is (1,1,1)
  66864. * @param extent x,y,z value that define the extent around the queries point of reference
  66865. */
  66866. setDefaultQueryExtent(extent: Vector3): void;
  66867. /**
  66868. * Get the Bounding box extent specified by setDefaultQueryExtent
  66869. * @returns the box extent values
  66870. */
  66871. getDefaultQueryExtent(): Vector3;
  66872. /**
  66873. * build the navmesh from a previously saved state using getNavmeshData
  66874. * @param data the Uint8Array returned by getNavmeshData
  66875. */
  66876. buildFromNavmeshData(data: Uint8Array): void;
  66877. /**
  66878. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66879. * @returns data the Uint8Array that can be saved and reused
  66880. */
  66881. getNavmeshData(): Uint8Array;
  66882. /**
  66883. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66884. * @param result output the box extent values
  66885. */
  66886. getDefaultQueryExtentToRef(result: Vector3): void;
  66887. /**
  66888. * Release all resources
  66889. */
  66890. dispose(): void;
  66891. }
  66892. /**
  66893. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66894. */
  66895. export interface ICrowd {
  66896. /**
  66897. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66898. * You can attach anything to that node. The node position is updated in the scene update tick.
  66899. * @param pos world position that will be constrained by the navigation mesh
  66900. * @param parameters agent parameters
  66901. * @param transform hooked to the agent that will be update by the scene
  66902. * @returns agent index
  66903. */
  66904. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66905. /**
  66906. * Returns the agent position in world space
  66907. * @param index agent index returned by addAgent
  66908. * @returns world space position
  66909. */
  66910. getAgentPosition(index: number): Vector3;
  66911. /**
  66912. * Gets the agent position result in world space
  66913. * @param index agent index returned by addAgent
  66914. * @param result output world space position
  66915. */
  66916. getAgentPositionToRef(index: number, result: Vector3): void;
  66917. /**
  66918. * Gets the agent velocity in world space
  66919. * @param index agent index returned by addAgent
  66920. * @returns world space velocity
  66921. */
  66922. getAgentVelocity(index: number): Vector3;
  66923. /**
  66924. * Gets the agent velocity result in world space
  66925. * @param index agent index returned by addAgent
  66926. * @param result output world space velocity
  66927. */
  66928. getAgentVelocityToRef(index: number, result: Vector3): void;
  66929. /**
  66930. * remove a particular agent previously created
  66931. * @param index agent index returned by addAgent
  66932. */
  66933. removeAgent(index: number): void;
  66934. /**
  66935. * get the list of all agents attached to this crowd
  66936. * @returns list of agent indices
  66937. */
  66938. getAgents(): number[];
  66939. /**
  66940. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66941. * @param deltaTime in seconds
  66942. */
  66943. update(deltaTime: number): void;
  66944. /**
  66945. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66946. * @param index agent index returned by addAgent
  66947. * @param destination targeted world position
  66948. */
  66949. agentGoto(index: number, destination: Vector3): void;
  66950. /**
  66951. * Teleport the agent to a new position
  66952. * @param index agent index returned by addAgent
  66953. * @param destination targeted world position
  66954. */
  66955. agentTeleport(index: number, destination: Vector3): void;
  66956. /**
  66957. * Update agent parameters
  66958. * @param index agent index returned by addAgent
  66959. * @param parameters agent parameters
  66960. */
  66961. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66962. /**
  66963. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66964. * The queries will try to find a solution within those bounds
  66965. * default is (1,1,1)
  66966. * @param extent x,y,z value that define the extent around the queries point of reference
  66967. */
  66968. setDefaultQueryExtent(extent: Vector3): void;
  66969. /**
  66970. * Get the Bounding box extent specified by setDefaultQueryExtent
  66971. * @returns the box extent values
  66972. */
  66973. getDefaultQueryExtent(): Vector3;
  66974. /**
  66975. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66976. * @param result output the box extent values
  66977. */
  66978. getDefaultQueryExtentToRef(result: Vector3): void;
  66979. /**
  66980. * Release all resources
  66981. */
  66982. dispose(): void;
  66983. }
  66984. /**
  66985. * Configures an agent
  66986. */
  66987. export interface IAgentParameters {
  66988. /**
  66989. * Agent radius. [Limit: >= 0]
  66990. */
  66991. radius: number;
  66992. /**
  66993. * Agent height. [Limit: > 0]
  66994. */
  66995. height: number;
  66996. /**
  66997. * Maximum allowed acceleration. [Limit: >= 0]
  66998. */
  66999. maxAcceleration: number;
  67000. /**
  67001. * Maximum allowed speed. [Limit: >= 0]
  67002. */
  67003. maxSpeed: number;
  67004. /**
  67005. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67006. */
  67007. collisionQueryRange: number;
  67008. /**
  67009. * The path visibility optimization range. [Limit: > 0]
  67010. */
  67011. pathOptimizationRange: number;
  67012. /**
  67013. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67014. */
  67015. separationWeight: number;
  67016. }
  67017. /**
  67018. * Configures the navigation mesh creation
  67019. */
  67020. export interface INavMeshParameters {
  67021. /**
  67022. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67023. */
  67024. cs: number;
  67025. /**
  67026. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67027. */
  67028. ch: number;
  67029. /**
  67030. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67031. */
  67032. walkableSlopeAngle: number;
  67033. /**
  67034. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67035. * be considered walkable. [Limit: >= 3] [Units: vx]
  67036. */
  67037. walkableHeight: number;
  67038. /**
  67039. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67040. */
  67041. walkableClimb: number;
  67042. /**
  67043. * The distance to erode/shrink the walkable area of the heightfield away from
  67044. * obstructions. [Limit: >=0] [Units: vx]
  67045. */
  67046. walkableRadius: number;
  67047. /**
  67048. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67049. */
  67050. maxEdgeLen: number;
  67051. /**
  67052. * The maximum distance a simplfied contour's border edges should deviate
  67053. * the original raw contour. [Limit: >=0] [Units: vx]
  67054. */
  67055. maxSimplificationError: number;
  67056. /**
  67057. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67058. */
  67059. minRegionArea: number;
  67060. /**
  67061. * Any regions with a span count smaller than this value will, if possible,
  67062. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67063. */
  67064. mergeRegionArea: number;
  67065. /**
  67066. * The maximum number of vertices allowed for polygons generated during the
  67067. * contour to polygon conversion process. [Limit: >= 3]
  67068. */
  67069. maxVertsPerPoly: number;
  67070. /**
  67071. * Sets the sampling distance to use when generating the detail mesh.
  67072. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67073. */
  67074. detailSampleDist: number;
  67075. /**
  67076. * The maximum distance the detail mesh surface should deviate from heightfield
  67077. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67078. */
  67079. detailSampleMaxError: number;
  67080. }
  67081. }
  67082. declare module BABYLON {
  67083. /**
  67084. * RecastJS navigation plugin
  67085. */
  67086. export class RecastJSPlugin implements INavigationEnginePlugin {
  67087. /**
  67088. * Reference to the Recast library
  67089. */
  67090. bjsRECAST: any;
  67091. /**
  67092. * plugin name
  67093. */
  67094. name: string;
  67095. /**
  67096. * the first navmesh created. We might extend this to support multiple navmeshes
  67097. */
  67098. navMesh: any;
  67099. /**
  67100. * Initializes the recastJS plugin
  67101. * @param recastInjection can be used to inject your own recast reference
  67102. */
  67103. constructor(recastInjection?: any);
  67104. /**
  67105. * Creates a navigation mesh
  67106. * @param meshes array of all the geometry used to compute the navigatio mesh
  67107. * @param parameters bunch of parameters used to filter geometry
  67108. */
  67109. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67110. /**
  67111. * Create a navigation mesh debug mesh
  67112. * @param scene is where the mesh will be added
  67113. * @returns debug display mesh
  67114. */
  67115. createDebugNavMesh(scene: Scene): Mesh;
  67116. /**
  67117. * Get a navigation mesh constrained position, closest to the parameter position
  67118. * @param position world position
  67119. * @returns the closest point to position constrained by the navigation mesh
  67120. */
  67121. getClosestPoint(position: Vector3): Vector3;
  67122. /**
  67123. * Get a navigation mesh constrained position, closest to the parameter position
  67124. * @param position world position
  67125. * @param result output the closest point to position constrained by the navigation mesh
  67126. */
  67127. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67128. /**
  67129. * Get a navigation mesh constrained position, within a particular radius
  67130. * @param position world position
  67131. * @param maxRadius the maximum distance to the constrained world position
  67132. * @returns the closest point to position constrained by the navigation mesh
  67133. */
  67134. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67135. /**
  67136. * Get a navigation mesh constrained position, within a particular radius
  67137. * @param position world position
  67138. * @param maxRadius the maximum distance to the constrained world position
  67139. * @param result output the closest point to position constrained by the navigation mesh
  67140. */
  67141. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67142. /**
  67143. * Compute the final position from a segment made of destination-position
  67144. * @param position world position
  67145. * @param destination world position
  67146. * @returns the resulting point along the navmesh
  67147. */
  67148. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67149. /**
  67150. * Compute the final position from a segment made of destination-position
  67151. * @param position world position
  67152. * @param destination world position
  67153. * @param result output the resulting point along the navmesh
  67154. */
  67155. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67156. /**
  67157. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67158. * @param start world position
  67159. * @param end world position
  67160. * @returns array containing world position composing the path
  67161. */
  67162. computePath(start: Vector3, end: Vector3): Vector3[];
  67163. /**
  67164. * Create a new Crowd so you can add agents
  67165. * @param maxAgents the maximum agent count in the crowd
  67166. * @param maxAgentRadius the maximum radius an agent can have
  67167. * @param scene to attach the crowd to
  67168. * @returns the crowd you can add agents to
  67169. */
  67170. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67171. /**
  67172. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67173. * The queries will try to find a solution within those bounds
  67174. * default is (1,1,1)
  67175. * @param extent x,y,z value that define the extent around the queries point of reference
  67176. */
  67177. setDefaultQueryExtent(extent: Vector3): void;
  67178. /**
  67179. * Get the Bounding box extent specified by setDefaultQueryExtent
  67180. * @returns the box extent values
  67181. */
  67182. getDefaultQueryExtent(): Vector3;
  67183. /**
  67184. * build the navmesh from a previously saved state using getNavmeshData
  67185. * @param data the Uint8Array returned by getNavmeshData
  67186. */
  67187. buildFromNavmeshData(data: Uint8Array): void;
  67188. /**
  67189. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67190. * @returns data the Uint8Array that can be saved and reused
  67191. */
  67192. getNavmeshData(): Uint8Array;
  67193. /**
  67194. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67195. * @param result output the box extent values
  67196. */
  67197. getDefaultQueryExtentToRef(result: Vector3): void;
  67198. /**
  67199. * Disposes
  67200. */
  67201. dispose(): void;
  67202. /**
  67203. * If this plugin is supported
  67204. * @returns true if plugin is supported
  67205. */
  67206. isSupported(): boolean;
  67207. }
  67208. /**
  67209. * Recast detour crowd implementation
  67210. */
  67211. export class RecastJSCrowd implements ICrowd {
  67212. /**
  67213. * Recast/detour plugin
  67214. */
  67215. bjsRECASTPlugin: RecastJSPlugin;
  67216. /**
  67217. * Link to the detour crowd
  67218. */
  67219. recastCrowd: any;
  67220. /**
  67221. * One transform per agent
  67222. */
  67223. transforms: TransformNode[];
  67224. /**
  67225. * All agents created
  67226. */
  67227. agents: number[];
  67228. /**
  67229. * Link to the scene is kept to unregister the crowd from the scene
  67230. */
  67231. private _scene;
  67232. /**
  67233. * Observer for crowd updates
  67234. */
  67235. private _onBeforeAnimationsObserver;
  67236. /**
  67237. * Constructor
  67238. * @param plugin recastJS plugin
  67239. * @param maxAgents the maximum agent count in the crowd
  67240. * @param maxAgentRadius the maximum radius an agent can have
  67241. * @param scene to attach the crowd to
  67242. * @returns the crowd you can add agents to
  67243. */
  67244. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67245. /**
  67246. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67247. * You can attach anything to that node. The node position is updated in the scene update tick.
  67248. * @param pos world position that will be constrained by the navigation mesh
  67249. * @param parameters agent parameters
  67250. * @param transform hooked to the agent that will be update by the scene
  67251. * @returns agent index
  67252. */
  67253. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67254. /**
  67255. * Returns the agent position in world space
  67256. * @param index agent index returned by addAgent
  67257. * @returns world space position
  67258. */
  67259. getAgentPosition(index: number): Vector3;
  67260. /**
  67261. * Returns the agent position result in world space
  67262. * @param index agent index returned by addAgent
  67263. * @param result output world space position
  67264. */
  67265. getAgentPositionToRef(index: number, result: Vector3): void;
  67266. /**
  67267. * Returns the agent velocity in world space
  67268. * @param index agent index returned by addAgent
  67269. * @returns world space velocity
  67270. */
  67271. getAgentVelocity(index: number): Vector3;
  67272. /**
  67273. * Returns the agent velocity result in world space
  67274. * @param index agent index returned by addAgent
  67275. * @param result output world space velocity
  67276. */
  67277. getAgentVelocityToRef(index: number, result: Vector3): void;
  67278. /**
  67279. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67280. * @param index agent index returned by addAgent
  67281. * @param destination targeted world position
  67282. */
  67283. agentGoto(index: number, destination: Vector3): void;
  67284. /**
  67285. * Teleport the agent to a new position
  67286. * @param index agent index returned by addAgent
  67287. * @param destination targeted world position
  67288. */
  67289. agentTeleport(index: number, destination: Vector3): void;
  67290. /**
  67291. * Update agent parameters
  67292. * @param index agent index returned by addAgent
  67293. * @param parameters agent parameters
  67294. */
  67295. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67296. /**
  67297. * remove a particular agent previously created
  67298. * @param index agent index returned by addAgent
  67299. */
  67300. removeAgent(index: number): void;
  67301. /**
  67302. * get the list of all agents attached to this crowd
  67303. * @returns list of agent indices
  67304. */
  67305. getAgents(): number[];
  67306. /**
  67307. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67308. * @param deltaTime in seconds
  67309. */
  67310. update(deltaTime: number): void;
  67311. /**
  67312. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67313. * The queries will try to find a solution within those bounds
  67314. * default is (1,1,1)
  67315. * @param extent x,y,z value that define the extent around the queries point of reference
  67316. */
  67317. setDefaultQueryExtent(extent: Vector3): void;
  67318. /**
  67319. * Get the Bounding box extent specified by setDefaultQueryExtent
  67320. * @returns the box extent values
  67321. */
  67322. getDefaultQueryExtent(): Vector3;
  67323. /**
  67324. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67325. * @param result output the box extent values
  67326. */
  67327. getDefaultQueryExtentToRef(result: Vector3): void;
  67328. /**
  67329. * Release all resources
  67330. */
  67331. dispose(): void;
  67332. }
  67333. }
  67334. declare module BABYLON {
  67335. /**
  67336. * Class used to enable access to IndexedDB
  67337. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67338. */
  67339. export class Database implements IOfflineProvider {
  67340. private _callbackManifestChecked;
  67341. private _currentSceneUrl;
  67342. private _db;
  67343. private _enableSceneOffline;
  67344. private _enableTexturesOffline;
  67345. private _manifestVersionFound;
  67346. private _mustUpdateRessources;
  67347. private _hasReachedQuota;
  67348. private _isSupported;
  67349. private _idbFactory;
  67350. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67351. private static IsUASupportingBlobStorage;
  67352. /**
  67353. * Gets a boolean indicating if Database storate is enabled (off by default)
  67354. */
  67355. static IDBStorageEnabled: boolean;
  67356. /**
  67357. * Gets a boolean indicating if scene must be saved in the database
  67358. */
  67359. get enableSceneOffline(): boolean;
  67360. /**
  67361. * Gets a boolean indicating if textures must be saved in the database
  67362. */
  67363. get enableTexturesOffline(): boolean;
  67364. /**
  67365. * Creates a new Database
  67366. * @param urlToScene defines the url to load the scene
  67367. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67368. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67369. */
  67370. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67371. private static _ParseURL;
  67372. private static _ReturnFullUrlLocation;
  67373. private _checkManifestFile;
  67374. /**
  67375. * Open the database and make it available
  67376. * @param successCallback defines the callback to call on success
  67377. * @param errorCallback defines the callback to call on error
  67378. */
  67379. open(successCallback: () => void, errorCallback: () => void): void;
  67380. /**
  67381. * Loads an image from the database
  67382. * @param url defines the url to load from
  67383. * @param image defines the target DOM image
  67384. */
  67385. loadImage(url: string, image: HTMLImageElement): void;
  67386. private _loadImageFromDBAsync;
  67387. private _saveImageIntoDBAsync;
  67388. private _checkVersionFromDB;
  67389. private _loadVersionFromDBAsync;
  67390. private _saveVersionIntoDBAsync;
  67391. /**
  67392. * Loads a file from database
  67393. * @param url defines the URL to load from
  67394. * @param sceneLoaded defines a callback to call on success
  67395. * @param progressCallBack defines a callback to call when progress changed
  67396. * @param errorCallback defines a callback to call on error
  67397. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67398. */
  67399. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67400. private _loadFileAsync;
  67401. private _saveFileAsync;
  67402. /**
  67403. * Validates if xhr data is correct
  67404. * @param xhr defines the request to validate
  67405. * @param dataType defines the expected data type
  67406. * @returns true if data is correct
  67407. */
  67408. private static _ValidateXHRData;
  67409. }
  67410. }
  67411. declare module BABYLON {
  67412. /** @hidden */
  67413. export var gpuUpdateParticlesPixelShader: {
  67414. name: string;
  67415. shader: string;
  67416. };
  67417. }
  67418. declare module BABYLON {
  67419. /** @hidden */
  67420. export var gpuUpdateParticlesVertexShader: {
  67421. name: string;
  67422. shader: string;
  67423. };
  67424. }
  67425. declare module BABYLON {
  67426. /** @hidden */
  67427. export var clipPlaneFragmentDeclaration2: {
  67428. name: string;
  67429. shader: string;
  67430. };
  67431. }
  67432. declare module BABYLON {
  67433. /** @hidden */
  67434. export var gpuRenderParticlesPixelShader: {
  67435. name: string;
  67436. shader: string;
  67437. };
  67438. }
  67439. declare module BABYLON {
  67440. /** @hidden */
  67441. export var clipPlaneVertexDeclaration2: {
  67442. name: string;
  67443. shader: string;
  67444. };
  67445. }
  67446. declare module BABYLON {
  67447. /** @hidden */
  67448. export var gpuRenderParticlesVertexShader: {
  67449. name: string;
  67450. shader: string;
  67451. };
  67452. }
  67453. declare module BABYLON {
  67454. /**
  67455. * This represents a GPU particle system in Babylon
  67456. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67457. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67458. */
  67459. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67460. /**
  67461. * The layer mask we are rendering the particles through.
  67462. */
  67463. layerMask: number;
  67464. private _capacity;
  67465. private _activeCount;
  67466. private _currentActiveCount;
  67467. private _accumulatedCount;
  67468. private _renderEffect;
  67469. private _updateEffect;
  67470. private _buffer0;
  67471. private _buffer1;
  67472. private _spriteBuffer;
  67473. private _updateVAO;
  67474. private _renderVAO;
  67475. private _targetIndex;
  67476. private _sourceBuffer;
  67477. private _targetBuffer;
  67478. private _currentRenderId;
  67479. private _started;
  67480. private _stopped;
  67481. private _timeDelta;
  67482. private _randomTexture;
  67483. private _randomTexture2;
  67484. private _attributesStrideSize;
  67485. private _updateEffectOptions;
  67486. private _randomTextureSize;
  67487. private _actualFrame;
  67488. private _customEffect;
  67489. private readonly _rawTextureWidth;
  67490. /**
  67491. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67492. */
  67493. static get IsSupported(): boolean;
  67494. /**
  67495. * An event triggered when the system is disposed.
  67496. */
  67497. onDisposeObservable: Observable<IParticleSystem>;
  67498. /**
  67499. * Gets the maximum number of particles active at the same time.
  67500. * @returns The max number of active particles.
  67501. */
  67502. getCapacity(): number;
  67503. /**
  67504. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67505. * to override the particles.
  67506. */
  67507. forceDepthWrite: boolean;
  67508. /**
  67509. * Gets or set the number of active particles
  67510. */
  67511. get activeParticleCount(): number;
  67512. set activeParticleCount(value: number);
  67513. private _preWarmDone;
  67514. /**
  67515. * Specifies if the particles are updated in emitter local space or world space.
  67516. */
  67517. isLocal: boolean;
  67518. /** Gets or sets a matrix to use to compute projection */
  67519. defaultProjectionMatrix: Matrix;
  67520. /**
  67521. * Is this system ready to be used/rendered
  67522. * @return true if the system is ready
  67523. */
  67524. isReady(): boolean;
  67525. /**
  67526. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67527. * @returns True if it has been started, otherwise false.
  67528. */
  67529. isStarted(): boolean;
  67530. /**
  67531. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67532. * @returns True if it has been stopped, otherwise false.
  67533. */
  67534. isStopped(): boolean;
  67535. /**
  67536. * Gets a boolean indicating that the system is stopping
  67537. * @returns true if the system is currently stopping
  67538. */
  67539. isStopping(): boolean;
  67540. /**
  67541. * Gets the number of particles active at the same time.
  67542. * @returns The number of active particles.
  67543. */
  67544. getActiveCount(): number;
  67545. /**
  67546. * Starts the particle system and begins to emit
  67547. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67548. */
  67549. start(delay?: number): void;
  67550. /**
  67551. * Stops the particle system.
  67552. */
  67553. stop(): void;
  67554. /**
  67555. * Remove all active particles
  67556. */
  67557. reset(): void;
  67558. /**
  67559. * Returns the string "GPUParticleSystem"
  67560. * @returns a string containing the class name
  67561. */
  67562. getClassName(): string;
  67563. /**
  67564. * Gets the custom effect used to render the particles
  67565. * @param blendMode Blend mode for which the effect should be retrieved
  67566. * @returns The effect
  67567. */
  67568. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67569. /**
  67570. * Sets the custom effect used to render the particles
  67571. * @param effect The effect to set
  67572. * @param blendMode Blend mode for which the effect should be set
  67573. */
  67574. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67575. /** @hidden */
  67576. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67577. /**
  67578. * Observable that will be called just before the particles are drawn
  67579. */
  67580. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67581. /**
  67582. * Gets the name of the particle vertex shader
  67583. */
  67584. get vertexShaderName(): string;
  67585. private _colorGradientsTexture;
  67586. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67587. /**
  67588. * Adds a new color gradient
  67589. * @param gradient defines the gradient to use (between 0 and 1)
  67590. * @param color1 defines the color to affect to the specified gradient
  67591. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67592. * @returns the current particle system
  67593. */
  67594. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67595. private _refreshColorGradient;
  67596. /** Force the system to rebuild all gradients that need to be resync */
  67597. forceRefreshGradients(): void;
  67598. /**
  67599. * Remove a specific color gradient
  67600. * @param gradient defines the gradient to remove
  67601. * @returns the current particle system
  67602. */
  67603. removeColorGradient(gradient: number): GPUParticleSystem;
  67604. private _angularSpeedGradientsTexture;
  67605. private _sizeGradientsTexture;
  67606. private _velocityGradientsTexture;
  67607. private _limitVelocityGradientsTexture;
  67608. private _dragGradientsTexture;
  67609. private _addFactorGradient;
  67610. /**
  67611. * Adds a new size gradient
  67612. * @param gradient defines the gradient to use (between 0 and 1)
  67613. * @param factor defines the size factor to affect to the specified gradient
  67614. * @returns the current particle system
  67615. */
  67616. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67617. /**
  67618. * Remove a specific size gradient
  67619. * @param gradient defines the gradient to remove
  67620. * @returns the current particle system
  67621. */
  67622. removeSizeGradient(gradient: number): GPUParticleSystem;
  67623. private _refreshFactorGradient;
  67624. /**
  67625. * Adds a new angular speed gradient
  67626. * @param gradient defines the gradient to use (between 0 and 1)
  67627. * @param factor defines the angular speed to affect to the specified gradient
  67628. * @returns the current particle system
  67629. */
  67630. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67631. /**
  67632. * Remove a specific angular speed gradient
  67633. * @param gradient defines the gradient to remove
  67634. * @returns the current particle system
  67635. */
  67636. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67637. /**
  67638. * Adds a new velocity gradient
  67639. * @param gradient defines the gradient to use (between 0 and 1)
  67640. * @param factor defines the velocity to affect to the specified gradient
  67641. * @returns the current particle system
  67642. */
  67643. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67644. /**
  67645. * Remove a specific velocity gradient
  67646. * @param gradient defines the gradient to remove
  67647. * @returns the current particle system
  67648. */
  67649. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67650. /**
  67651. * Adds a new limit velocity gradient
  67652. * @param gradient defines the gradient to use (between 0 and 1)
  67653. * @param factor defines the limit velocity value to affect to the specified gradient
  67654. * @returns the current particle system
  67655. */
  67656. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67657. /**
  67658. * Remove a specific limit velocity gradient
  67659. * @param gradient defines the gradient to remove
  67660. * @returns the current particle system
  67661. */
  67662. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67663. /**
  67664. * Adds a new drag gradient
  67665. * @param gradient defines the gradient to use (between 0 and 1)
  67666. * @param factor defines the drag value to affect to the specified gradient
  67667. * @returns the current particle system
  67668. */
  67669. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67670. /**
  67671. * Remove a specific drag gradient
  67672. * @param gradient defines the gradient to remove
  67673. * @returns the current particle system
  67674. */
  67675. removeDragGradient(gradient: number): GPUParticleSystem;
  67676. /**
  67677. * Not supported by GPUParticleSystem
  67678. * @param gradient defines the gradient to use (between 0 and 1)
  67679. * @param factor defines the emit rate value to affect to the specified gradient
  67680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67681. * @returns the current particle system
  67682. */
  67683. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67684. /**
  67685. * Not supported by GPUParticleSystem
  67686. * @param gradient defines the gradient to remove
  67687. * @returns the current particle system
  67688. */
  67689. removeEmitRateGradient(gradient: number): IParticleSystem;
  67690. /**
  67691. * Not supported by GPUParticleSystem
  67692. * @param gradient defines the gradient to use (between 0 and 1)
  67693. * @param factor defines the start size value to affect to the specified gradient
  67694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67695. * @returns the current particle system
  67696. */
  67697. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67698. /**
  67699. * Not supported by GPUParticleSystem
  67700. * @param gradient defines the gradient to remove
  67701. * @returns the current particle system
  67702. */
  67703. removeStartSizeGradient(gradient: number): IParticleSystem;
  67704. /**
  67705. * Not supported by GPUParticleSystem
  67706. * @param gradient defines the gradient to use (between 0 and 1)
  67707. * @param min defines the color remap minimal range
  67708. * @param max defines the color remap maximal range
  67709. * @returns the current particle system
  67710. */
  67711. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67712. /**
  67713. * Not supported by GPUParticleSystem
  67714. * @param gradient defines the gradient to remove
  67715. * @returns the current particle system
  67716. */
  67717. removeColorRemapGradient(): IParticleSystem;
  67718. /**
  67719. * Not supported by GPUParticleSystem
  67720. * @param gradient defines the gradient to use (between 0 and 1)
  67721. * @param min defines the alpha remap minimal range
  67722. * @param max defines the alpha remap maximal range
  67723. * @returns the current particle system
  67724. */
  67725. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67726. /**
  67727. * Not supported by GPUParticleSystem
  67728. * @param gradient defines the gradient to remove
  67729. * @returns the current particle system
  67730. */
  67731. removeAlphaRemapGradient(): IParticleSystem;
  67732. /**
  67733. * Not supported by GPUParticleSystem
  67734. * @param gradient defines the gradient to use (between 0 and 1)
  67735. * @param color defines the color to affect to the specified gradient
  67736. * @returns the current particle system
  67737. */
  67738. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67739. /**
  67740. * Not supported by GPUParticleSystem
  67741. * @param gradient defines the gradient to remove
  67742. * @returns the current particle system
  67743. */
  67744. removeRampGradient(): IParticleSystem;
  67745. /**
  67746. * Not supported by GPUParticleSystem
  67747. * @returns the list of ramp gradients
  67748. */
  67749. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67750. /**
  67751. * Not supported by GPUParticleSystem
  67752. * Gets or sets a boolean indicating that ramp gradients must be used
  67753. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67754. */
  67755. get useRampGradients(): boolean;
  67756. set useRampGradients(value: boolean);
  67757. /**
  67758. * Not supported by GPUParticleSystem
  67759. * @param gradient defines the gradient to use (between 0 and 1)
  67760. * @param factor defines the life time factor to affect to the specified gradient
  67761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67762. * @returns the current particle system
  67763. */
  67764. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67765. /**
  67766. * Not supported by GPUParticleSystem
  67767. * @param gradient defines the gradient to remove
  67768. * @returns the current particle system
  67769. */
  67770. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67771. /**
  67772. * Instantiates a GPU particle system.
  67773. * 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.
  67774. * @param name The name of the particle system
  67775. * @param options The options used to create the system
  67776. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67777. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67778. * @param customEffect a custom effect used to change the way particles are rendered by default
  67779. */
  67780. constructor(name: string, options: Partial<{
  67781. capacity: number;
  67782. randomTextureSize: number;
  67783. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67784. protected _reset(): void;
  67785. private _createUpdateVAO;
  67786. private _createRenderVAO;
  67787. private _initialize;
  67788. /** @hidden */
  67789. _recreateUpdateEffect(): void;
  67790. private _getEffect;
  67791. /**
  67792. * Fill the defines array according to the current settings of the particle system
  67793. * @param defines Array to be updated
  67794. * @param blendMode blend mode to take into account when updating the array
  67795. */
  67796. fillDefines(defines: Array<string>, blendMode?: number): void;
  67797. /**
  67798. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67799. * @param uniforms Uniforms array to fill
  67800. * @param attributes Attributes array to fill
  67801. * @param samplers Samplers array to fill
  67802. */
  67803. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67804. /** @hidden */
  67805. _recreateRenderEffect(): Effect;
  67806. /**
  67807. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67808. * @param preWarm defines if we are in the pre-warmimg phase
  67809. */
  67810. animate(preWarm?: boolean): void;
  67811. private _createFactorGradientTexture;
  67812. private _createSizeGradientTexture;
  67813. private _createAngularSpeedGradientTexture;
  67814. private _createVelocityGradientTexture;
  67815. private _createLimitVelocityGradientTexture;
  67816. private _createDragGradientTexture;
  67817. private _createColorGradientTexture;
  67818. /**
  67819. * Renders the particle system in its current state
  67820. * @param preWarm defines if the system should only update the particles but not render them
  67821. * @returns the current number of particles
  67822. */
  67823. render(preWarm?: boolean): number;
  67824. /**
  67825. * Rebuilds the particle system
  67826. */
  67827. rebuild(): void;
  67828. private _releaseBuffers;
  67829. private _releaseVAOs;
  67830. /**
  67831. * Disposes the particle system and free the associated resources
  67832. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67833. */
  67834. dispose(disposeTexture?: boolean): void;
  67835. /**
  67836. * Clones the particle system.
  67837. * @param name The name of the cloned object
  67838. * @param newEmitter The new emitter to use
  67839. * @returns the cloned particle system
  67840. */
  67841. clone(name: string, newEmitter: any): GPUParticleSystem;
  67842. /**
  67843. * Serializes the particle system to a JSON object
  67844. * @param serializeTexture defines if the texture must be serialized as well
  67845. * @returns the JSON object
  67846. */
  67847. serialize(serializeTexture?: boolean): any;
  67848. /**
  67849. * Parses a JSON object to create a GPU particle system.
  67850. * @param parsedParticleSystem The JSON object to parse
  67851. * @param sceneOrEngine The scene or the engine to create the particle system in
  67852. * @param rootUrl The root url to use to load external dependencies like texture
  67853. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67854. * @returns the parsed GPU particle system
  67855. */
  67856. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67857. }
  67858. }
  67859. declare module BABYLON {
  67860. /**
  67861. * Represents a set of particle systems working together to create a specific effect
  67862. */
  67863. export class ParticleSystemSet implements IDisposable {
  67864. /**
  67865. * Gets or sets base Assets URL
  67866. */
  67867. static BaseAssetsUrl: string;
  67868. private _emitterCreationOptions;
  67869. private _emitterNode;
  67870. /**
  67871. * Gets the particle system list
  67872. */
  67873. systems: IParticleSystem[];
  67874. /**
  67875. * Gets the emitter node used with this set
  67876. */
  67877. get emitterNode(): Nullable<TransformNode>;
  67878. /**
  67879. * Creates a new emitter mesh as a sphere
  67880. * @param options defines the options used to create the sphere
  67881. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67882. * @param scene defines the hosting scene
  67883. */
  67884. setEmitterAsSphere(options: {
  67885. diameter: number;
  67886. segments: number;
  67887. color: Color3;
  67888. }, renderingGroupId: number, scene: Scene): void;
  67889. /**
  67890. * Starts all particle systems of the set
  67891. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67892. */
  67893. start(emitter?: AbstractMesh): void;
  67894. /**
  67895. * Release all associated resources
  67896. */
  67897. dispose(): void;
  67898. /**
  67899. * Serialize the set into a JSON compatible object
  67900. * @param serializeTexture defines if the texture must be serialized as well
  67901. * @returns a JSON compatible representation of the set
  67902. */
  67903. serialize(serializeTexture?: boolean): any;
  67904. /**
  67905. * Parse a new ParticleSystemSet from a serialized source
  67906. * @param data defines a JSON compatible representation of the set
  67907. * @param scene defines the hosting scene
  67908. * @param gpu defines if we want GPU particles or CPU particles
  67909. * @returns a new ParticleSystemSet
  67910. */
  67911. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67912. }
  67913. }
  67914. declare module BABYLON {
  67915. /**
  67916. * This class is made for on one-liner static method to help creating particle system set.
  67917. */
  67918. export class ParticleHelper {
  67919. /**
  67920. * Gets or sets base Assets URL
  67921. */
  67922. static BaseAssetsUrl: string;
  67923. /** Define the Url to load snippets */
  67924. static SnippetUrl: string;
  67925. /**
  67926. * Create a default particle system that you can tweak
  67927. * @param emitter defines the emitter to use
  67928. * @param capacity defines the system capacity (default is 500 particles)
  67929. * @param scene defines the hosting scene
  67930. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67931. * @returns the new Particle system
  67932. */
  67933. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67934. /**
  67935. * This is the main static method (one-liner) of this helper to create different particle systems
  67936. * @param type This string represents the type to the particle system to create
  67937. * @param scene The scene where the particle system should live
  67938. * @param gpu If the system will use gpu
  67939. * @returns the ParticleSystemSet created
  67940. */
  67941. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67942. /**
  67943. * Static function used to export a particle system to a ParticleSystemSet variable.
  67944. * Please note that the emitter shape is not exported
  67945. * @param systems defines the particle systems to export
  67946. * @returns the created particle system set
  67947. */
  67948. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67949. /**
  67950. * Creates a particle system from a snippet saved in a remote file
  67951. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67952. * @param url defines the url to load from
  67953. * @param scene defines the hosting scene
  67954. * @param gpu If the system will use gpu
  67955. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67956. * @returns a promise that will resolve to the new particle system
  67957. */
  67958. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67959. /**
  67960. * Creates a particle system from a snippet saved by the particle system editor
  67961. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67962. * @param scene defines the hosting scene
  67963. * @param gpu If the system will use gpu
  67964. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67965. * @returns a promise that will resolve to the new particle system
  67966. */
  67967. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. interface Engine {
  67972. /**
  67973. * Create an effect to use with particle systems.
  67974. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67975. * the particle system for which you want to create a custom effect in the last parameter
  67976. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67977. * @param uniformsNames defines a list of attribute names
  67978. * @param samplers defines an array of string used to represent textures
  67979. * @param defines defines the string containing the defines to use to compile the shaders
  67980. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67981. * @param onCompiled defines a function to call when the effect creation is successful
  67982. * @param onError defines a function to call when the effect creation has failed
  67983. * @param particleSystem the particle system you want to create the effect for
  67984. * @returns the new Effect
  67985. */
  67986. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67987. }
  67988. interface Mesh {
  67989. /**
  67990. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67991. * @returns an array of IParticleSystem
  67992. */
  67993. getEmittedParticleSystems(): IParticleSystem[];
  67994. /**
  67995. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67996. * @returns an array of IParticleSystem
  67997. */
  67998. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67999. }
  68000. }
  68001. declare module BABYLON {
  68002. /** Defines the 4 color options */
  68003. export enum PointColor {
  68004. /** color value */
  68005. Color = 2,
  68006. /** uv value */
  68007. UV = 1,
  68008. /** random value */
  68009. Random = 0,
  68010. /** stated value */
  68011. Stated = 3
  68012. }
  68013. /**
  68014. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68015. * 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.
  68016. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68017. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68018. *
  68019. * Full documentation here : TO BE ENTERED
  68020. */
  68021. export class PointsCloudSystem implements IDisposable {
  68022. /**
  68023. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68024. * Example : var p = SPS.particles[i];
  68025. */
  68026. particles: CloudPoint[];
  68027. /**
  68028. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68029. */
  68030. nbParticles: number;
  68031. /**
  68032. * This a counter for your own usage. It's not set by any SPS functions.
  68033. */
  68034. counter: number;
  68035. /**
  68036. * The PCS name. This name is also given to the underlying mesh.
  68037. */
  68038. name: string;
  68039. /**
  68040. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68041. */
  68042. mesh: Mesh;
  68043. /**
  68044. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68045. * Please read :
  68046. */
  68047. vars: any;
  68048. /**
  68049. * @hidden
  68050. */
  68051. _size: number;
  68052. private _scene;
  68053. private _promises;
  68054. private _positions;
  68055. private _indices;
  68056. private _normals;
  68057. private _colors;
  68058. private _uvs;
  68059. private _indices32;
  68060. private _positions32;
  68061. private _colors32;
  68062. private _uvs32;
  68063. private _updatable;
  68064. private _isVisibilityBoxLocked;
  68065. private _alwaysVisible;
  68066. private _groups;
  68067. private _groupCounter;
  68068. private _computeParticleColor;
  68069. private _computeParticleTexture;
  68070. private _computeParticleRotation;
  68071. private _computeBoundingBox;
  68072. private _isReady;
  68073. /**
  68074. * Creates a PCS (Points Cloud System) object
  68075. * @param name (String) is the PCS name, this will be the underlying mesh name
  68076. * @param pointSize (number) is the size for each point
  68077. * @param scene (Scene) is the scene in which the PCS is added
  68078. * @param options defines the options of the PCS e.g.
  68079. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68080. */
  68081. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68082. updatable?: boolean;
  68083. });
  68084. /**
  68085. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68086. * If no points were added to the PCS, the returned mesh is just a single point.
  68087. * @returns a promise for the created mesh
  68088. */
  68089. buildMeshAsync(): Promise<Mesh>;
  68090. /**
  68091. * @hidden
  68092. */
  68093. private _buildMesh;
  68094. private _addParticle;
  68095. private _randomUnitVector;
  68096. private _getColorIndicesForCoord;
  68097. private _setPointsColorOrUV;
  68098. private _colorFromTexture;
  68099. private _calculateDensity;
  68100. /**
  68101. * Adds points to the PCS in random positions within a unit sphere
  68102. * @param nb (positive integer) the number of particles to be created from this model
  68103. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68104. * @returns the number of groups in the system
  68105. */
  68106. addPoints(nb: number, pointFunction?: any): number;
  68107. /**
  68108. * Adds points to the PCS from the surface of the model shape
  68109. * @param mesh is any Mesh object that will be used as a surface model for the points
  68110. * @param nb (positive integer) the number of particles to be created from this model
  68111. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68112. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68113. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68114. * @returns the number of groups in the system
  68115. */
  68116. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68117. /**
  68118. * Adds points to the PCS inside the model shape
  68119. * @param mesh is any Mesh object that will be used as a surface model for the points
  68120. * @param nb (positive integer) the number of particles to be created from this model
  68121. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68122. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68123. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68124. * @returns the number of groups in the system
  68125. */
  68126. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68127. /**
  68128. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68129. * This method calls `updateParticle()` for each particle of the SPS.
  68130. * For an animated SPS, it is usually called within the render loop.
  68131. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68132. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68133. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68134. * @returns the PCS.
  68135. */
  68136. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68137. /**
  68138. * Disposes the PCS.
  68139. */
  68140. dispose(): void;
  68141. /**
  68142. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68143. * doc :
  68144. * @returns the PCS.
  68145. */
  68146. refreshVisibleSize(): PointsCloudSystem;
  68147. /**
  68148. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68149. * @param size the size (float) of the visibility box
  68150. * note : this doesn't lock the PCS mesh bounding box.
  68151. * doc :
  68152. */
  68153. setVisibilityBox(size: number): void;
  68154. /**
  68155. * Gets whether the PCS is always visible or not
  68156. * doc :
  68157. */
  68158. get isAlwaysVisible(): boolean;
  68159. /**
  68160. * Sets the PCS as always visible or not
  68161. * doc :
  68162. */
  68163. set isAlwaysVisible(val: boolean);
  68164. /**
  68165. * Tells to `setParticles()` to compute the particle rotations or not
  68166. * Default value : false. The PCS is faster when it's set to false
  68167. * Note : particle rotations are only applied to parent particles
  68168. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68169. */
  68170. set computeParticleRotation(val: boolean);
  68171. /**
  68172. * Tells to `setParticles()` to compute the particle colors or not.
  68173. * Default value : true. The PCS is faster when it's set to false.
  68174. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68175. */
  68176. set computeParticleColor(val: boolean);
  68177. set computeParticleTexture(val: boolean);
  68178. /**
  68179. * Gets if `setParticles()` computes the particle colors or not.
  68180. * Default value : false. The PCS is faster when it's set to false.
  68181. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68182. */
  68183. get computeParticleColor(): boolean;
  68184. /**
  68185. * Gets if `setParticles()` computes the particle textures or not.
  68186. * Default value : false. The PCS is faster when it's set to false.
  68187. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68188. */
  68189. get computeParticleTexture(): boolean;
  68190. /**
  68191. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68192. */
  68193. set computeBoundingBox(val: boolean);
  68194. /**
  68195. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68196. */
  68197. get computeBoundingBox(): boolean;
  68198. /**
  68199. * This function does nothing. It may be overwritten to set all the particle first values.
  68200. * The PCS doesn't call this function, you may have to call it by your own.
  68201. * doc :
  68202. */
  68203. initParticles(): void;
  68204. /**
  68205. * This function does nothing. It may be overwritten to recycle a particle
  68206. * The PCS doesn't call this function, you can to call it
  68207. * doc :
  68208. * @param particle The particle to recycle
  68209. * @returns the recycled particle
  68210. */
  68211. recycleParticle(particle: CloudPoint): CloudPoint;
  68212. /**
  68213. * Updates a particle : this function should be overwritten by the user.
  68214. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68215. * doc :
  68216. * @example : just set a particle position or velocity and recycle conditions
  68217. * @param particle The particle to update
  68218. * @returns the updated particle
  68219. */
  68220. updateParticle(particle: CloudPoint): CloudPoint;
  68221. /**
  68222. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68223. * This does nothing and may be overwritten by the user.
  68224. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68225. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68226. * @param update the boolean update value actually passed to setParticles()
  68227. */
  68228. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68229. /**
  68230. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68231. * This will be passed three parameters.
  68232. * This does nothing and may be overwritten by the user.
  68233. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68234. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68235. * @param update the boolean update value actually passed to setParticles()
  68236. */
  68237. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68238. }
  68239. }
  68240. declare module BABYLON {
  68241. /**
  68242. * Represents one particle of a points cloud system.
  68243. */
  68244. export class CloudPoint {
  68245. /**
  68246. * particle global index
  68247. */
  68248. idx: number;
  68249. /**
  68250. * The color of the particle
  68251. */
  68252. color: Nullable<Color4>;
  68253. /**
  68254. * The world space position of the particle.
  68255. */
  68256. position: Vector3;
  68257. /**
  68258. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68259. */
  68260. rotation: Vector3;
  68261. /**
  68262. * The world space rotation quaternion of the particle.
  68263. */
  68264. rotationQuaternion: Nullable<Quaternion>;
  68265. /**
  68266. * The uv of the particle.
  68267. */
  68268. uv: Nullable<Vector2>;
  68269. /**
  68270. * The current speed of the particle.
  68271. */
  68272. velocity: Vector3;
  68273. /**
  68274. * The pivot point in the particle local space.
  68275. */
  68276. pivot: Vector3;
  68277. /**
  68278. * Must the particle be translated from its pivot point in its local space ?
  68279. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68280. * Default : false
  68281. */
  68282. translateFromPivot: boolean;
  68283. /**
  68284. * Index of this particle in the global "positions" array (Internal use)
  68285. * @hidden
  68286. */
  68287. _pos: number;
  68288. /**
  68289. * @hidden Index of this particle in the global "indices" array (Internal use)
  68290. */
  68291. _ind: number;
  68292. /**
  68293. * Group this particle belongs to
  68294. */
  68295. _group: PointsGroup;
  68296. /**
  68297. * Group id of this particle
  68298. */
  68299. groupId: number;
  68300. /**
  68301. * Index of the particle in its group id (Internal use)
  68302. */
  68303. idxInGroup: number;
  68304. /**
  68305. * @hidden Particle BoundingInfo object (Internal use)
  68306. */
  68307. _boundingInfo: BoundingInfo;
  68308. /**
  68309. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68310. */
  68311. _pcs: PointsCloudSystem;
  68312. /**
  68313. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68314. */
  68315. _stillInvisible: boolean;
  68316. /**
  68317. * @hidden Last computed particle rotation matrix
  68318. */
  68319. _rotationMatrix: number[];
  68320. /**
  68321. * Parent particle Id, if any.
  68322. * Default null.
  68323. */
  68324. parentId: Nullable<number>;
  68325. /**
  68326. * @hidden Internal global position in the PCS.
  68327. */
  68328. _globalPosition: Vector3;
  68329. /**
  68330. * Creates a Point Cloud object.
  68331. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68332. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68333. * @param group (PointsGroup) is the group the particle belongs to
  68334. * @param groupId (integer) is the group identifier in the PCS.
  68335. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68336. * @param pcs defines the PCS it is associated to
  68337. */
  68338. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68339. /**
  68340. * get point size
  68341. */
  68342. get size(): Vector3;
  68343. /**
  68344. * Set point size
  68345. */
  68346. set size(scale: Vector3);
  68347. /**
  68348. * Legacy support, changed quaternion to rotationQuaternion
  68349. */
  68350. get quaternion(): Nullable<Quaternion>;
  68351. /**
  68352. * Legacy support, changed quaternion to rotationQuaternion
  68353. */
  68354. set quaternion(q: Nullable<Quaternion>);
  68355. /**
  68356. * Returns a boolean. True if the particle intersects a mesh, else false
  68357. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68358. * @param target is the object (point or mesh) what the intersection is computed against
  68359. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68360. * @returns true if it intersects
  68361. */
  68362. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68363. /**
  68364. * get the rotation matrix of the particle
  68365. * @hidden
  68366. */
  68367. getRotationMatrix(m: Matrix): void;
  68368. }
  68369. /**
  68370. * Represents a group of points in a points cloud system
  68371. * * PCS internal tool, don't use it manually.
  68372. */
  68373. export class PointsGroup {
  68374. /**
  68375. * The group id
  68376. * @hidden
  68377. */
  68378. groupID: number;
  68379. /**
  68380. * image data for group (internal use)
  68381. * @hidden
  68382. */
  68383. _groupImageData: Nullable<ArrayBufferView>;
  68384. /**
  68385. * Image Width (internal use)
  68386. * @hidden
  68387. */
  68388. _groupImgWidth: number;
  68389. /**
  68390. * Image Height (internal use)
  68391. * @hidden
  68392. */
  68393. _groupImgHeight: number;
  68394. /**
  68395. * Custom position function (internal use)
  68396. * @hidden
  68397. */
  68398. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68399. /**
  68400. * density per facet for surface points
  68401. * @hidden
  68402. */
  68403. _groupDensity: number[];
  68404. /**
  68405. * Only when points are colored by texture carries pointer to texture list array
  68406. * @hidden
  68407. */
  68408. _textureNb: number;
  68409. /**
  68410. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68411. * PCS internal tool, don't use it manually.
  68412. * @hidden
  68413. */
  68414. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68415. }
  68416. }
  68417. declare module BABYLON {
  68418. interface Scene {
  68419. /** @hidden (Backing field) */
  68420. _physicsEngine: Nullable<IPhysicsEngine>;
  68421. /** @hidden */
  68422. _physicsTimeAccumulator: number;
  68423. /**
  68424. * Gets the current physics engine
  68425. * @returns a IPhysicsEngine or null if none attached
  68426. */
  68427. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68428. /**
  68429. * Enables physics to the current scene
  68430. * @param gravity defines the scene's gravity for the physics engine
  68431. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68432. * @return a boolean indicating if the physics engine was initialized
  68433. */
  68434. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68435. /**
  68436. * Disables and disposes the physics engine associated with the scene
  68437. */
  68438. disablePhysicsEngine(): void;
  68439. /**
  68440. * Gets a boolean indicating if there is an active physics engine
  68441. * @returns a boolean indicating if there is an active physics engine
  68442. */
  68443. isPhysicsEnabled(): boolean;
  68444. /**
  68445. * Deletes a physics compound impostor
  68446. * @param compound defines the compound to delete
  68447. */
  68448. deleteCompoundImpostor(compound: any): void;
  68449. /**
  68450. * An event triggered when physic simulation is about to be run
  68451. */
  68452. onBeforePhysicsObservable: Observable<Scene>;
  68453. /**
  68454. * An event triggered when physic simulation has been done
  68455. */
  68456. onAfterPhysicsObservable: Observable<Scene>;
  68457. }
  68458. interface AbstractMesh {
  68459. /** @hidden */
  68460. _physicsImpostor: Nullable<PhysicsImpostor>;
  68461. /**
  68462. * Gets or sets impostor used for physic simulation
  68463. * @see https://doc.babylonjs.com/features/physics_engine
  68464. */
  68465. physicsImpostor: Nullable<PhysicsImpostor>;
  68466. /**
  68467. * Gets the current physics impostor
  68468. * @see https://doc.babylonjs.com/features/physics_engine
  68469. * @returns a physics impostor or null
  68470. */
  68471. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68472. /** Apply a physic impulse to the mesh
  68473. * @param force defines the force to apply
  68474. * @param contactPoint defines where to apply the force
  68475. * @returns the current mesh
  68476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68477. */
  68478. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68479. /**
  68480. * Creates a physic joint between two meshes
  68481. * @param otherMesh defines the other mesh to use
  68482. * @param pivot1 defines the pivot to use on this mesh
  68483. * @param pivot2 defines the pivot to use on the other mesh
  68484. * @param options defines additional options (can be plugin dependent)
  68485. * @returns the current mesh
  68486. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68487. */
  68488. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68489. /** @hidden */
  68490. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68491. }
  68492. /**
  68493. * Defines the physics engine scene component responsible to manage a physics engine
  68494. */
  68495. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68496. /**
  68497. * The component name helpful to identify the component in the list of scene components.
  68498. */
  68499. readonly name: string;
  68500. /**
  68501. * The scene the component belongs to.
  68502. */
  68503. scene: Scene;
  68504. /**
  68505. * Creates a new instance of the component for the given scene
  68506. * @param scene Defines the scene to register the component in
  68507. */
  68508. constructor(scene: Scene);
  68509. /**
  68510. * Registers the component in a given scene
  68511. */
  68512. register(): void;
  68513. /**
  68514. * Rebuilds the elements related to this component in case of
  68515. * context lost for instance.
  68516. */
  68517. rebuild(): void;
  68518. /**
  68519. * Disposes the component and the associated ressources
  68520. */
  68521. dispose(): void;
  68522. }
  68523. }
  68524. declare module BABYLON {
  68525. /**
  68526. * A helper for physics simulations
  68527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68528. */
  68529. export class PhysicsHelper {
  68530. private _scene;
  68531. private _physicsEngine;
  68532. /**
  68533. * Initializes the Physics helper
  68534. * @param scene Babylon.js scene
  68535. */
  68536. constructor(scene: Scene);
  68537. /**
  68538. * Applies a radial explosion impulse
  68539. * @param origin the origin of the explosion
  68540. * @param radiusOrEventOptions the radius or the options of radial explosion
  68541. * @param strength the explosion strength
  68542. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68543. * @returns A physics radial explosion event, or null
  68544. */
  68545. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68546. /**
  68547. * Applies a radial explosion force
  68548. * @param origin the origin of the explosion
  68549. * @param radiusOrEventOptions the radius or the options of radial explosion
  68550. * @param strength the explosion strength
  68551. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68552. * @returns A physics radial explosion event, or null
  68553. */
  68554. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68555. /**
  68556. * Creates a gravitational field
  68557. * @param origin the origin of the explosion
  68558. * @param radiusOrEventOptions the radius or the options of radial explosion
  68559. * @param strength the explosion strength
  68560. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68561. * @returns A physics gravitational field event, or null
  68562. */
  68563. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68564. /**
  68565. * Creates a physics updraft event
  68566. * @param origin the origin of the updraft
  68567. * @param radiusOrEventOptions the radius or the options of the updraft
  68568. * @param strength the strength of the updraft
  68569. * @param height the height of the updraft
  68570. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68571. * @returns A physics updraft event, or null
  68572. */
  68573. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68574. /**
  68575. * Creates a physics vortex event
  68576. * @param origin the of the vortex
  68577. * @param radiusOrEventOptions the radius or the options of the vortex
  68578. * @param strength the strength of the vortex
  68579. * @param height the height of the vortex
  68580. * @returns a Physics vortex event, or null
  68581. * A physics vortex event or null
  68582. */
  68583. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68584. }
  68585. /**
  68586. * Represents a physics radial explosion event
  68587. */
  68588. class PhysicsRadialExplosionEvent {
  68589. private _scene;
  68590. private _options;
  68591. private _sphere;
  68592. private _dataFetched;
  68593. /**
  68594. * Initializes a radial explosioin event
  68595. * @param _scene BabylonJS scene
  68596. * @param _options The options for the vortex event
  68597. */
  68598. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68599. /**
  68600. * Returns the data related to the radial explosion event (sphere).
  68601. * @returns The radial explosion event data
  68602. */
  68603. getData(): PhysicsRadialExplosionEventData;
  68604. /**
  68605. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68606. * @param impostor A physics imposter
  68607. * @param origin the origin of the explosion
  68608. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68609. */
  68610. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68611. /**
  68612. * Triggers affecterd impostors callbacks
  68613. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68614. */
  68615. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68616. /**
  68617. * Disposes the sphere.
  68618. * @param force Specifies if the sphere should be disposed by force
  68619. */
  68620. dispose(force?: boolean): void;
  68621. /*** Helpers ***/
  68622. private _prepareSphere;
  68623. private _intersectsWithSphere;
  68624. }
  68625. /**
  68626. * Represents a gravitational field event
  68627. */
  68628. class PhysicsGravitationalFieldEvent {
  68629. private _physicsHelper;
  68630. private _scene;
  68631. private _origin;
  68632. private _options;
  68633. private _tickCallback;
  68634. private _sphere;
  68635. private _dataFetched;
  68636. /**
  68637. * Initializes the physics gravitational field event
  68638. * @param _physicsHelper A physics helper
  68639. * @param _scene BabylonJS scene
  68640. * @param _origin The origin position of the gravitational field event
  68641. * @param _options The options for the vortex event
  68642. */
  68643. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68644. /**
  68645. * Returns the data related to the gravitational field event (sphere).
  68646. * @returns A gravitational field event
  68647. */
  68648. getData(): PhysicsGravitationalFieldEventData;
  68649. /**
  68650. * Enables the gravitational field.
  68651. */
  68652. enable(): void;
  68653. /**
  68654. * Disables the gravitational field.
  68655. */
  68656. disable(): void;
  68657. /**
  68658. * Disposes the sphere.
  68659. * @param force The force to dispose from the gravitational field event
  68660. */
  68661. dispose(force?: boolean): void;
  68662. private _tick;
  68663. }
  68664. /**
  68665. * Represents a physics updraft event
  68666. */
  68667. class PhysicsUpdraftEvent {
  68668. private _scene;
  68669. private _origin;
  68670. private _options;
  68671. private _physicsEngine;
  68672. private _originTop;
  68673. private _originDirection;
  68674. private _tickCallback;
  68675. private _cylinder;
  68676. private _cylinderPosition;
  68677. private _dataFetched;
  68678. /**
  68679. * Initializes the physics updraft event
  68680. * @param _scene BabylonJS scene
  68681. * @param _origin The origin position of the updraft
  68682. * @param _options The options for the updraft event
  68683. */
  68684. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68685. /**
  68686. * Returns the data related to the updraft event (cylinder).
  68687. * @returns A physics updraft event
  68688. */
  68689. getData(): PhysicsUpdraftEventData;
  68690. /**
  68691. * Enables the updraft.
  68692. */
  68693. enable(): void;
  68694. /**
  68695. * Disables the updraft.
  68696. */
  68697. disable(): void;
  68698. /**
  68699. * Disposes the cylinder.
  68700. * @param force Specifies if the updraft should be disposed by force
  68701. */
  68702. dispose(force?: boolean): void;
  68703. private getImpostorHitData;
  68704. private _tick;
  68705. /*** Helpers ***/
  68706. private _prepareCylinder;
  68707. private _intersectsWithCylinder;
  68708. }
  68709. /**
  68710. * Represents a physics vortex event
  68711. */
  68712. class PhysicsVortexEvent {
  68713. private _scene;
  68714. private _origin;
  68715. private _options;
  68716. private _physicsEngine;
  68717. private _originTop;
  68718. private _tickCallback;
  68719. private _cylinder;
  68720. private _cylinderPosition;
  68721. private _dataFetched;
  68722. /**
  68723. * Initializes the physics vortex event
  68724. * @param _scene The BabylonJS scene
  68725. * @param _origin The origin position of the vortex
  68726. * @param _options The options for the vortex event
  68727. */
  68728. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68729. /**
  68730. * Returns the data related to the vortex event (cylinder).
  68731. * @returns The physics vortex event data
  68732. */
  68733. getData(): PhysicsVortexEventData;
  68734. /**
  68735. * Enables the vortex.
  68736. */
  68737. enable(): void;
  68738. /**
  68739. * Disables the cortex.
  68740. */
  68741. disable(): void;
  68742. /**
  68743. * Disposes the sphere.
  68744. * @param force
  68745. */
  68746. dispose(force?: boolean): void;
  68747. private getImpostorHitData;
  68748. private _tick;
  68749. /*** Helpers ***/
  68750. private _prepareCylinder;
  68751. private _intersectsWithCylinder;
  68752. }
  68753. /**
  68754. * Options fot the radial explosion event
  68755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68756. */
  68757. export class PhysicsRadialExplosionEventOptions {
  68758. /**
  68759. * The radius of the sphere for the radial explosion.
  68760. */
  68761. radius: number;
  68762. /**
  68763. * The strenth of the explosion.
  68764. */
  68765. strength: number;
  68766. /**
  68767. * The strenght of the force in correspondence to the distance of the affected object
  68768. */
  68769. falloff: PhysicsRadialImpulseFalloff;
  68770. /**
  68771. * Sphere options for the radial explosion.
  68772. */
  68773. sphere: {
  68774. segments: number;
  68775. diameter: number;
  68776. };
  68777. /**
  68778. * Sphere options for the radial explosion.
  68779. */
  68780. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68781. }
  68782. /**
  68783. * Options fot the updraft event
  68784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68785. */
  68786. export class PhysicsUpdraftEventOptions {
  68787. /**
  68788. * The radius of the cylinder for the vortex
  68789. */
  68790. radius: number;
  68791. /**
  68792. * The strenth of the updraft.
  68793. */
  68794. strength: number;
  68795. /**
  68796. * The height of the cylinder for the updraft.
  68797. */
  68798. height: number;
  68799. /**
  68800. * The mode for the the updraft.
  68801. */
  68802. updraftMode: PhysicsUpdraftMode;
  68803. }
  68804. /**
  68805. * Options fot the vortex event
  68806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68807. */
  68808. export class PhysicsVortexEventOptions {
  68809. /**
  68810. * The radius of the cylinder for the vortex
  68811. */
  68812. radius: number;
  68813. /**
  68814. * The strenth of the vortex.
  68815. */
  68816. strength: number;
  68817. /**
  68818. * The height of the cylinder for the vortex.
  68819. */
  68820. height: number;
  68821. /**
  68822. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68823. */
  68824. centripetalForceThreshold: number;
  68825. /**
  68826. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68827. */
  68828. centripetalForceMultiplier: number;
  68829. /**
  68830. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68831. */
  68832. centrifugalForceMultiplier: number;
  68833. /**
  68834. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68835. */
  68836. updraftForceMultiplier: number;
  68837. }
  68838. /**
  68839. * The strenght of the force in correspondence to the distance of the affected object
  68840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68841. */
  68842. export enum PhysicsRadialImpulseFalloff {
  68843. /** Defines that impulse is constant in strength across it's whole radius */
  68844. Constant = 0,
  68845. /** Defines that impulse gets weaker if it's further from the origin */
  68846. Linear = 1
  68847. }
  68848. /**
  68849. * The strength of the force in correspondence to the distance of the affected object
  68850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68851. */
  68852. export enum PhysicsUpdraftMode {
  68853. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68854. Center = 0,
  68855. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68856. Perpendicular = 1
  68857. }
  68858. /**
  68859. * Interface for a physics hit data
  68860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68861. */
  68862. export interface PhysicsHitData {
  68863. /**
  68864. * The force applied at the contact point
  68865. */
  68866. force: Vector3;
  68867. /**
  68868. * The contact point
  68869. */
  68870. contactPoint: Vector3;
  68871. /**
  68872. * The distance from the origin to the contact point
  68873. */
  68874. distanceFromOrigin: number;
  68875. }
  68876. /**
  68877. * Interface for radial explosion event data
  68878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68879. */
  68880. export interface PhysicsRadialExplosionEventData {
  68881. /**
  68882. * A sphere used for the radial explosion event
  68883. */
  68884. sphere: Mesh;
  68885. }
  68886. /**
  68887. * Interface for gravitational field event data
  68888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68889. */
  68890. export interface PhysicsGravitationalFieldEventData {
  68891. /**
  68892. * A sphere mesh used for the gravitational field event
  68893. */
  68894. sphere: Mesh;
  68895. }
  68896. /**
  68897. * Interface for updraft event data
  68898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68899. */
  68900. export interface PhysicsUpdraftEventData {
  68901. /**
  68902. * A cylinder used for the updraft event
  68903. */
  68904. cylinder: Mesh;
  68905. }
  68906. /**
  68907. * Interface for vortex event data
  68908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68909. */
  68910. export interface PhysicsVortexEventData {
  68911. /**
  68912. * A cylinder used for the vortex event
  68913. */
  68914. cylinder: Mesh;
  68915. }
  68916. /**
  68917. * Interface for an affected physics impostor
  68918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68919. */
  68920. export interface PhysicsAffectedImpostorWithData {
  68921. /**
  68922. * The impostor affected by the effect
  68923. */
  68924. impostor: PhysicsImpostor;
  68925. /**
  68926. * The data about the hit/horce from the explosion
  68927. */
  68928. hitData: PhysicsHitData;
  68929. }
  68930. }
  68931. declare module BABYLON {
  68932. /** @hidden */
  68933. export var blackAndWhitePixelShader: {
  68934. name: string;
  68935. shader: string;
  68936. };
  68937. }
  68938. declare module BABYLON {
  68939. /**
  68940. * Post process used to render in black and white
  68941. */
  68942. export class BlackAndWhitePostProcess extends PostProcess {
  68943. /**
  68944. * Linear about to convert he result to black and white (default: 1)
  68945. */
  68946. degree: number;
  68947. /**
  68948. * Gets a string identifying the name of the class
  68949. * @returns "BlackAndWhitePostProcess" string
  68950. */
  68951. getClassName(): string;
  68952. /**
  68953. * Creates a black and white post process
  68954. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68955. * @param name The name of the effect.
  68956. * @param options The required width/height ratio to downsize to before computing the render pass.
  68957. * @param camera The camera to apply the render pass to.
  68958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68959. * @param engine The engine which the post process will be applied. (default: current engine)
  68960. * @param reusable If the post process can be reused on the same frame. (default: false)
  68961. */
  68962. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68963. /** @hidden */
  68964. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68965. }
  68966. }
  68967. declare module BABYLON {
  68968. /**
  68969. * This represents a set of one or more post processes in Babylon.
  68970. * A post process can be used to apply a shader to a texture after it is rendered.
  68971. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68972. */
  68973. export class PostProcessRenderEffect {
  68974. private _postProcesses;
  68975. private _getPostProcesses;
  68976. private _singleInstance;
  68977. private _cameras;
  68978. private _indicesForCamera;
  68979. /**
  68980. * Name of the effect
  68981. * @hidden
  68982. */
  68983. _name: string;
  68984. /**
  68985. * Instantiates a post process render effect.
  68986. * A post process can be used to apply a shader to a texture after it is rendered.
  68987. * @param engine The engine the effect is tied to
  68988. * @param name The name of the effect
  68989. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68990. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68991. */
  68992. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68993. /**
  68994. * Checks if all the post processes in the effect are supported.
  68995. */
  68996. get isSupported(): boolean;
  68997. /**
  68998. * Updates the current state of the effect
  68999. * @hidden
  69000. */
  69001. _update(): void;
  69002. /**
  69003. * Attaches the effect on cameras
  69004. * @param cameras The camera to attach to.
  69005. * @hidden
  69006. */
  69007. _attachCameras(cameras: Camera): void;
  69008. /**
  69009. * Attaches the effect on cameras
  69010. * @param cameras The camera to attach to.
  69011. * @hidden
  69012. */
  69013. _attachCameras(cameras: Camera[]): void;
  69014. /**
  69015. * Detaches the effect on cameras
  69016. * @param cameras The camera to detatch from.
  69017. * @hidden
  69018. */
  69019. _detachCameras(cameras: Camera): void;
  69020. /**
  69021. * Detatches the effect on cameras
  69022. * @param cameras The camera to detatch from.
  69023. * @hidden
  69024. */
  69025. _detachCameras(cameras: Camera[]): void;
  69026. /**
  69027. * Enables the effect on given cameras
  69028. * @param cameras The camera to enable.
  69029. * @hidden
  69030. */
  69031. _enable(cameras: Camera): void;
  69032. /**
  69033. * Enables the effect on given cameras
  69034. * @param cameras The camera to enable.
  69035. * @hidden
  69036. */
  69037. _enable(cameras: Nullable<Camera[]>): void;
  69038. /**
  69039. * Disables the effect on the given cameras
  69040. * @param cameras The camera to disable.
  69041. * @hidden
  69042. */
  69043. _disable(cameras: Camera): void;
  69044. /**
  69045. * Disables the effect on the given cameras
  69046. * @param cameras The camera to disable.
  69047. * @hidden
  69048. */
  69049. _disable(cameras: Nullable<Camera[]>): void;
  69050. /**
  69051. * Gets a list of the post processes contained in the effect.
  69052. * @param camera The camera to get the post processes on.
  69053. * @returns The list of the post processes in the effect.
  69054. */
  69055. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69056. }
  69057. }
  69058. declare module BABYLON {
  69059. /** @hidden */
  69060. export var extractHighlightsPixelShader: {
  69061. name: string;
  69062. shader: string;
  69063. };
  69064. }
  69065. declare module BABYLON {
  69066. /**
  69067. * 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.
  69068. */
  69069. export class ExtractHighlightsPostProcess extends PostProcess {
  69070. /**
  69071. * The luminance threshold, pixels below this value will be set to black.
  69072. */
  69073. threshold: number;
  69074. /** @hidden */
  69075. _exposure: number;
  69076. /**
  69077. * Post process which has the input texture to be used when performing highlight extraction
  69078. * @hidden
  69079. */
  69080. _inputPostProcess: Nullable<PostProcess>;
  69081. /**
  69082. * Gets a string identifying the name of the class
  69083. * @returns "ExtractHighlightsPostProcess" string
  69084. */
  69085. getClassName(): string;
  69086. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69087. }
  69088. }
  69089. declare module BABYLON {
  69090. /** @hidden */
  69091. export var bloomMergePixelShader: {
  69092. name: string;
  69093. shader: string;
  69094. };
  69095. }
  69096. declare module BABYLON {
  69097. /**
  69098. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69099. */
  69100. export class BloomMergePostProcess extends PostProcess {
  69101. /** Weight of the bloom to be added to the original input. */
  69102. weight: number;
  69103. /**
  69104. * Gets a string identifying the name of the class
  69105. * @returns "BloomMergePostProcess" string
  69106. */
  69107. getClassName(): string;
  69108. /**
  69109. * Creates a new instance of @see BloomMergePostProcess
  69110. * @param name The name of the effect.
  69111. * @param originalFromInput Post process which's input will be used for the merge.
  69112. * @param blurred Blurred highlights post process which's output will be used.
  69113. * @param weight Weight of the bloom to be added to the original input.
  69114. * @param options The required width/height ratio to downsize to before computing the render pass.
  69115. * @param camera The camera to apply the render pass to.
  69116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69117. * @param engine The engine which the post process will be applied. (default: current engine)
  69118. * @param reusable If the post process can be reused on the same frame. (default: false)
  69119. * @param textureType Type of textures used when performing the post process. (default: 0)
  69120. * @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)
  69121. */
  69122. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69123. /** Weight of the bloom to be added to the original input. */
  69124. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69125. }
  69126. }
  69127. declare module BABYLON {
  69128. /**
  69129. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69130. */
  69131. export class BloomEffect extends PostProcessRenderEffect {
  69132. private bloomScale;
  69133. /**
  69134. * @hidden Internal
  69135. */
  69136. _effects: Array<PostProcess>;
  69137. /**
  69138. * @hidden Internal
  69139. */
  69140. _downscale: ExtractHighlightsPostProcess;
  69141. private _blurX;
  69142. private _blurY;
  69143. private _merge;
  69144. /**
  69145. * The luminance threshold to find bright areas of the image to bloom.
  69146. */
  69147. get threshold(): number;
  69148. set threshold(value: number);
  69149. /**
  69150. * The strength of the bloom.
  69151. */
  69152. get weight(): number;
  69153. set weight(value: number);
  69154. /**
  69155. * Specifies the size of the bloom blur kernel, relative to the final output size
  69156. */
  69157. get kernel(): number;
  69158. set kernel(value: number);
  69159. /**
  69160. * Creates a new instance of @see BloomEffect
  69161. * @param scene The scene the effect belongs to.
  69162. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69163. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69164. * @param bloomWeight The the strength of bloom.
  69165. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69166. * @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)
  69167. */
  69168. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69169. /**
  69170. * Disposes each of the internal effects for a given camera.
  69171. * @param camera The camera to dispose the effect on.
  69172. */
  69173. disposeEffects(camera: Camera): void;
  69174. /**
  69175. * @hidden Internal
  69176. */
  69177. _updateEffects(): void;
  69178. /**
  69179. * Internal
  69180. * @returns if all the contained post processes are ready.
  69181. * @hidden
  69182. */
  69183. _isReady(): boolean;
  69184. }
  69185. }
  69186. declare module BABYLON {
  69187. /** @hidden */
  69188. export var chromaticAberrationPixelShader: {
  69189. name: string;
  69190. shader: string;
  69191. };
  69192. }
  69193. declare module BABYLON {
  69194. /**
  69195. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69196. */
  69197. export class ChromaticAberrationPostProcess extends PostProcess {
  69198. /**
  69199. * The amount of seperation of rgb channels (default: 30)
  69200. */
  69201. aberrationAmount: number;
  69202. /**
  69203. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69204. */
  69205. radialIntensity: number;
  69206. /**
  69207. * 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))
  69208. */
  69209. direction: Vector2;
  69210. /**
  69211. * 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))
  69212. */
  69213. centerPosition: Vector2;
  69214. /** The width of the screen to apply the effect on */
  69215. screenWidth: number;
  69216. /** The height of the screen to apply the effect on */
  69217. screenHeight: number;
  69218. /**
  69219. * Gets a string identifying the name of the class
  69220. * @returns "ChromaticAberrationPostProcess" string
  69221. */
  69222. getClassName(): string;
  69223. /**
  69224. * Creates a new instance ChromaticAberrationPostProcess
  69225. * @param name The name of the effect.
  69226. * @param screenWidth The width of the screen to apply the effect on.
  69227. * @param screenHeight The height of the screen to apply the effect on.
  69228. * @param options The required width/height ratio to downsize to before computing the render pass.
  69229. * @param camera The camera to apply the render pass to.
  69230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69231. * @param engine The engine which the post process will be applied. (default: current engine)
  69232. * @param reusable If the post process can be reused on the same frame. (default: false)
  69233. * @param textureType Type of textures used when performing the post process. (default: 0)
  69234. * @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)
  69235. */
  69236. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69237. /** @hidden */
  69238. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69239. }
  69240. }
  69241. declare module BABYLON {
  69242. /** @hidden */
  69243. export var circleOfConfusionPixelShader: {
  69244. name: string;
  69245. shader: string;
  69246. };
  69247. }
  69248. declare module BABYLON {
  69249. /**
  69250. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69251. */
  69252. export class CircleOfConfusionPostProcess extends PostProcess {
  69253. /**
  69254. * 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.
  69255. */
  69256. lensSize: number;
  69257. /**
  69258. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69259. */
  69260. fStop: number;
  69261. /**
  69262. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69263. */
  69264. focusDistance: number;
  69265. /**
  69266. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69267. */
  69268. focalLength: number;
  69269. /**
  69270. * Gets a string identifying the name of the class
  69271. * @returns "CircleOfConfusionPostProcess" string
  69272. */
  69273. getClassName(): string;
  69274. private _depthTexture;
  69275. /**
  69276. * Creates a new instance CircleOfConfusionPostProcess
  69277. * @param name The name of the effect.
  69278. * @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.
  69279. * @param options The required width/height ratio to downsize to before computing the render pass.
  69280. * @param camera The camera to apply the render pass to.
  69281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69282. * @param engine The engine which the post process will be applied. (default: current engine)
  69283. * @param reusable If the post process can be reused on the same frame. (default: false)
  69284. * @param textureType Type of textures used when performing the post process. (default: 0)
  69285. * @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)
  69286. */
  69287. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69288. /**
  69289. * 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.
  69290. */
  69291. set depthTexture(value: RenderTargetTexture);
  69292. }
  69293. }
  69294. declare module BABYLON {
  69295. /** @hidden */
  69296. export var colorCorrectionPixelShader: {
  69297. name: string;
  69298. shader: string;
  69299. };
  69300. }
  69301. declare module BABYLON {
  69302. /**
  69303. *
  69304. * This post-process allows the modification of rendered colors by using
  69305. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69306. *
  69307. * The object needs to be provided an url to a texture containing the color
  69308. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69309. * Use an image editing software to tweak the LUT to match your needs.
  69310. *
  69311. * For an example of a color LUT, see here:
  69312. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69313. * For explanations on color grading, see here:
  69314. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69315. *
  69316. */
  69317. export class ColorCorrectionPostProcess extends PostProcess {
  69318. private _colorTableTexture;
  69319. /**
  69320. * Gets the color table url used to create the LUT texture
  69321. */
  69322. colorTableUrl: string;
  69323. /**
  69324. * Gets a string identifying the name of the class
  69325. * @returns "ColorCorrectionPostProcess" string
  69326. */
  69327. getClassName(): string;
  69328. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69329. /** @hidden */
  69330. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69331. }
  69332. }
  69333. declare module BABYLON {
  69334. /** @hidden */
  69335. export var convolutionPixelShader: {
  69336. name: string;
  69337. shader: string;
  69338. };
  69339. }
  69340. declare module BABYLON {
  69341. /**
  69342. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69343. * input texture to perform effects such as edge detection or sharpening
  69344. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69345. */
  69346. export class ConvolutionPostProcess extends PostProcess {
  69347. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69348. kernel: number[];
  69349. /**
  69350. * Gets a string identifying the name of the class
  69351. * @returns "ConvolutionPostProcess" string
  69352. */
  69353. getClassName(): string;
  69354. /**
  69355. * Creates a new instance ConvolutionPostProcess
  69356. * @param name The name of the effect.
  69357. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69358. * @param options The required width/height ratio to downsize to before computing the render pass.
  69359. * @param camera The camera to apply the render pass to.
  69360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69361. * @param engine The engine which the post process will be applied. (default: current engine)
  69362. * @param reusable If the post process can be reused on the same frame. (default: false)
  69363. * @param textureType Type of textures used when performing the post process. (default: 0)
  69364. */
  69365. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69366. /** @hidden */
  69367. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69368. /**
  69369. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69370. */
  69371. static EdgeDetect0Kernel: number[];
  69372. /**
  69373. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69374. */
  69375. static EdgeDetect1Kernel: number[];
  69376. /**
  69377. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69378. */
  69379. static EdgeDetect2Kernel: number[];
  69380. /**
  69381. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69382. */
  69383. static SharpenKernel: number[];
  69384. /**
  69385. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69386. */
  69387. static EmbossKernel: number[];
  69388. /**
  69389. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69390. */
  69391. static GaussianKernel: number[];
  69392. }
  69393. }
  69394. declare module BABYLON {
  69395. /**
  69396. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69397. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69398. * based on samples that have a large difference in distance than the center pixel.
  69399. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69400. */
  69401. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69402. /**
  69403. * The direction the blur should be applied
  69404. */
  69405. direction: Vector2;
  69406. /**
  69407. * Gets a string identifying the name of the class
  69408. * @returns "DepthOfFieldBlurPostProcess" string
  69409. */
  69410. getClassName(): string;
  69411. /**
  69412. * Creates a new instance CircleOfConfusionPostProcess
  69413. * @param name The name of the effect.
  69414. * @param scene The scene the effect belongs to.
  69415. * @param direction The direction the blur should be applied.
  69416. * @param kernel The size of the kernel used to blur.
  69417. * @param options The required width/height ratio to downsize to before computing the render pass.
  69418. * @param camera The camera to apply the render pass to.
  69419. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69420. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69422. * @param engine The engine which the post process will be applied. (default: current engine)
  69423. * @param reusable If the post process can be reused on the same frame. (default: false)
  69424. * @param textureType Type of textures used when performing the post process. (default: 0)
  69425. * @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)
  69426. */
  69427. 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);
  69428. }
  69429. }
  69430. declare module BABYLON {
  69431. /** @hidden */
  69432. export var depthOfFieldMergePixelShader: {
  69433. name: string;
  69434. shader: string;
  69435. };
  69436. }
  69437. declare module BABYLON {
  69438. /**
  69439. * Options to be set when merging outputs from the default pipeline.
  69440. */
  69441. export class DepthOfFieldMergePostProcessOptions {
  69442. /**
  69443. * The original image to merge on top of
  69444. */
  69445. originalFromInput: PostProcess;
  69446. /**
  69447. * Parameters to perform the merge of the depth of field effect
  69448. */
  69449. depthOfField?: {
  69450. circleOfConfusion: PostProcess;
  69451. blurSteps: Array<PostProcess>;
  69452. };
  69453. /**
  69454. * Parameters to perform the merge of bloom effect
  69455. */
  69456. bloom?: {
  69457. blurred: PostProcess;
  69458. weight: number;
  69459. };
  69460. }
  69461. /**
  69462. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69463. */
  69464. export class DepthOfFieldMergePostProcess extends PostProcess {
  69465. private blurSteps;
  69466. /**
  69467. * Gets a string identifying the name of the class
  69468. * @returns "DepthOfFieldMergePostProcess" string
  69469. */
  69470. getClassName(): string;
  69471. /**
  69472. * Creates a new instance of DepthOfFieldMergePostProcess
  69473. * @param name The name of the effect.
  69474. * @param originalFromInput Post process which's input will be used for the merge.
  69475. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69476. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69477. * @param options The required width/height ratio to downsize to before computing the render pass.
  69478. * @param camera The camera to apply the render pass to.
  69479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69480. * @param engine The engine which the post process will be applied. (default: current engine)
  69481. * @param reusable If the post process can be reused on the same frame. (default: false)
  69482. * @param textureType Type of textures used when performing the post process. (default: 0)
  69483. * @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)
  69484. */
  69485. 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);
  69486. /**
  69487. * Updates the effect with the current post process compile time values and recompiles the shader.
  69488. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69489. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69490. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69491. * @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
  69492. * @param onCompiled Called when the shader has been compiled.
  69493. * @param onError Called if there is an error when compiling a shader.
  69494. */
  69495. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69496. }
  69497. }
  69498. declare module BABYLON {
  69499. /**
  69500. * Specifies the level of max blur that should be applied when using the depth of field effect
  69501. */
  69502. export enum DepthOfFieldEffectBlurLevel {
  69503. /**
  69504. * Subtle blur
  69505. */
  69506. Low = 0,
  69507. /**
  69508. * Medium blur
  69509. */
  69510. Medium = 1,
  69511. /**
  69512. * Large blur
  69513. */
  69514. High = 2
  69515. }
  69516. /**
  69517. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69518. */
  69519. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69520. private _circleOfConfusion;
  69521. /**
  69522. * @hidden Internal, blurs from high to low
  69523. */
  69524. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69525. private _depthOfFieldBlurY;
  69526. private _dofMerge;
  69527. /**
  69528. * @hidden Internal post processes in depth of field effect
  69529. */
  69530. _effects: Array<PostProcess>;
  69531. /**
  69532. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69533. */
  69534. set focalLength(value: number);
  69535. get focalLength(): number;
  69536. /**
  69537. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69538. */
  69539. set fStop(value: number);
  69540. get fStop(): number;
  69541. /**
  69542. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69543. */
  69544. set focusDistance(value: number);
  69545. get focusDistance(): number;
  69546. /**
  69547. * 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.
  69548. */
  69549. set lensSize(value: number);
  69550. get lensSize(): number;
  69551. /**
  69552. * Creates a new instance DepthOfFieldEffect
  69553. * @param scene The scene the effect belongs to.
  69554. * @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.
  69555. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69556. * @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)
  69557. */
  69558. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69559. /**
  69560. * Get the current class name of the current effet
  69561. * @returns "DepthOfFieldEffect"
  69562. */
  69563. getClassName(): string;
  69564. /**
  69565. * 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.
  69566. */
  69567. set depthTexture(value: RenderTargetTexture);
  69568. /**
  69569. * Disposes each of the internal effects for a given camera.
  69570. * @param camera The camera to dispose the effect on.
  69571. */
  69572. disposeEffects(camera: Camera): void;
  69573. /**
  69574. * @hidden Internal
  69575. */
  69576. _updateEffects(): void;
  69577. /**
  69578. * Internal
  69579. * @returns if all the contained post processes are ready.
  69580. * @hidden
  69581. */
  69582. _isReady(): boolean;
  69583. }
  69584. }
  69585. declare module BABYLON {
  69586. /** @hidden */
  69587. export var displayPassPixelShader: {
  69588. name: string;
  69589. shader: string;
  69590. };
  69591. }
  69592. declare module BABYLON {
  69593. /**
  69594. * DisplayPassPostProcess which produces an output the same as it's input
  69595. */
  69596. export class DisplayPassPostProcess extends PostProcess {
  69597. /**
  69598. * Gets a string identifying the name of the class
  69599. * @returns "DisplayPassPostProcess" string
  69600. */
  69601. getClassName(): string;
  69602. /**
  69603. * Creates the DisplayPassPostProcess
  69604. * @param name The name of the effect.
  69605. * @param options The required width/height ratio to downsize to before computing the render pass.
  69606. * @param camera The camera to apply the render pass to.
  69607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69608. * @param engine The engine which the post process will be applied. (default: current engine)
  69609. * @param reusable If the post process can be reused on the same frame. (default: false)
  69610. */
  69611. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69612. /** @hidden */
  69613. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69614. }
  69615. }
  69616. declare module BABYLON {
  69617. /** @hidden */
  69618. export var filterPixelShader: {
  69619. name: string;
  69620. shader: string;
  69621. };
  69622. }
  69623. declare module BABYLON {
  69624. /**
  69625. * Applies a kernel filter to the image
  69626. */
  69627. export class FilterPostProcess extends PostProcess {
  69628. /** The matrix to be applied to the image */
  69629. kernelMatrix: Matrix;
  69630. /**
  69631. * Gets a string identifying the name of the class
  69632. * @returns "FilterPostProcess" string
  69633. */
  69634. getClassName(): string;
  69635. /**
  69636. *
  69637. * @param name The name of the effect.
  69638. * @param kernelMatrix The matrix to be applied to the image
  69639. * @param options The required width/height ratio to downsize to before computing the render pass.
  69640. * @param camera The camera to apply the render pass to.
  69641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69642. * @param engine The engine which the post process will be applied. (default: current engine)
  69643. * @param reusable If the post process can be reused on the same frame. (default: false)
  69644. */
  69645. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69646. /** @hidden */
  69647. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69648. }
  69649. }
  69650. declare module BABYLON {
  69651. /** @hidden */
  69652. export var fxaaPixelShader: {
  69653. name: string;
  69654. shader: string;
  69655. };
  69656. }
  69657. declare module BABYLON {
  69658. /** @hidden */
  69659. export var fxaaVertexShader: {
  69660. name: string;
  69661. shader: string;
  69662. };
  69663. }
  69664. declare module BABYLON {
  69665. /**
  69666. * Fxaa post process
  69667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69668. */
  69669. export class FxaaPostProcess extends PostProcess {
  69670. /**
  69671. * Gets a string identifying the name of the class
  69672. * @returns "FxaaPostProcess" string
  69673. */
  69674. getClassName(): string;
  69675. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69676. private _getDefines;
  69677. /** @hidden */
  69678. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69679. }
  69680. }
  69681. declare module BABYLON {
  69682. /** @hidden */
  69683. export var grainPixelShader: {
  69684. name: string;
  69685. shader: string;
  69686. };
  69687. }
  69688. declare module BABYLON {
  69689. /**
  69690. * The GrainPostProcess adds noise to the image at mid luminance levels
  69691. */
  69692. export class GrainPostProcess extends PostProcess {
  69693. /**
  69694. * The intensity of the grain added (default: 30)
  69695. */
  69696. intensity: number;
  69697. /**
  69698. * If the grain should be randomized on every frame
  69699. */
  69700. animated: boolean;
  69701. /**
  69702. * Gets a string identifying the name of the class
  69703. * @returns "GrainPostProcess" string
  69704. */
  69705. getClassName(): string;
  69706. /**
  69707. * Creates a new instance of @see GrainPostProcess
  69708. * @param name The name of the effect.
  69709. * @param options The required width/height ratio to downsize to before computing the render pass.
  69710. * @param camera The camera to apply the render pass to.
  69711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69712. * @param engine The engine which the post process will be applied. (default: current engine)
  69713. * @param reusable If the post process can be reused on the same frame. (default: false)
  69714. * @param textureType Type of textures used when performing the post process. (default: 0)
  69715. * @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)
  69716. */
  69717. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69718. /** @hidden */
  69719. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69720. }
  69721. }
  69722. declare module BABYLON {
  69723. /** @hidden */
  69724. export var highlightsPixelShader: {
  69725. name: string;
  69726. shader: string;
  69727. };
  69728. }
  69729. declare module BABYLON {
  69730. /**
  69731. * Extracts highlights from the image
  69732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69733. */
  69734. export class HighlightsPostProcess extends PostProcess {
  69735. /**
  69736. * Gets a string identifying the name of the class
  69737. * @returns "HighlightsPostProcess" string
  69738. */
  69739. getClassName(): string;
  69740. /**
  69741. * Extracts highlights from the image
  69742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69743. * @param name The name of the effect.
  69744. * @param options The required width/height ratio to downsize to before computing the render pass.
  69745. * @param camera The camera to apply the render pass to.
  69746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69747. * @param engine The engine which the post process will be applied. (default: current engine)
  69748. * @param reusable If the post process can be reused on the same frame. (default: false)
  69749. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69750. */
  69751. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69752. }
  69753. }
  69754. declare module BABYLON {
  69755. /** @hidden */
  69756. export var mrtFragmentDeclaration: {
  69757. name: string;
  69758. shader: string;
  69759. };
  69760. }
  69761. declare module BABYLON {
  69762. /** @hidden */
  69763. export var geometryPixelShader: {
  69764. name: string;
  69765. shader: string;
  69766. };
  69767. }
  69768. declare module BABYLON {
  69769. /** @hidden */
  69770. export var geometryVertexShader: {
  69771. name: string;
  69772. shader: string;
  69773. };
  69774. }
  69775. declare module BABYLON {
  69776. /** @hidden */
  69777. interface ISavedTransformationMatrix {
  69778. world: Matrix;
  69779. viewProjection: Matrix;
  69780. }
  69781. /**
  69782. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69783. */
  69784. export class GeometryBufferRenderer {
  69785. /**
  69786. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69787. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69788. */
  69789. static readonly POSITION_TEXTURE_TYPE: number;
  69790. /**
  69791. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69792. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69793. */
  69794. static readonly VELOCITY_TEXTURE_TYPE: number;
  69795. /**
  69796. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69797. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69798. */
  69799. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69800. /**
  69801. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69802. * in order to compute objects velocities when enableVelocity is set to "true"
  69803. * @hidden
  69804. */
  69805. _previousTransformationMatrices: {
  69806. [index: number]: ISavedTransformationMatrix;
  69807. };
  69808. /**
  69809. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69810. * in order to compute objects velocities when enableVelocity is set to "true"
  69811. * @hidden
  69812. */
  69813. _previousBonesTransformationMatrices: {
  69814. [index: number]: Float32Array;
  69815. };
  69816. /**
  69817. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69818. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69819. */
  69820. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69821. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69822. renderTransparentMeshes: boolean;
  69823. private _scene;
  69824. private _resizeObserver;
  69825. private _multiRenderTarget;
  69826. private _ratio;
  69827. private _enablePosition;
  69828. private _enableVelocity;
  69829. private _enableReflectivity;
  69830. private _positionIndex;
  69831. private _velocityIndex;
  69832. private _reflectivityIndex;
  69833. protected _effect: Effect;
  69834. protected _cachedDefines: string;
  69835. /**
  69836. * Set the render list (meshes to be rendered) used in the G buffer.
  69837. */
  69838. set renderList(meshes: Mesh[]);
  69839. /**
  69840. * Gets wether or not G buffer are supported by the running hardware.
  69841. * This requires draw buffer supports
  69842. */
  69843. get isSupported(): boolean;
  69844. /**
  69845. * Returns the index of the given texture type in the G-Buffer textures array
  69846. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69847. * @returns the index of the given texture type in the G-Buffer textures array
  69848. */
  69849. getTextureIndex(textureType: number): number;
  69850. /**
  69851. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69852. */
  69853. get enablePosition(): boolean;
  69854. /**
  69855. * Sets whether or not objects positions are enabled for the G buffer.
  69856. */
  69857. set enablePosition(enable: boolean);
  69858. /**
  69859. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69860. */
  69861. get enableVelocity(): boolean;
  69862. /**
  69863. * Sets wether or not objects velocities are enabled for the G buffer.
  69864. */
  69865. set enableVelocity(enable: boolean);
  69866. /**
  69867. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69868. */
  69869. get enableReflectivity(): boolean;
  69870. /**
  69871. * Sets wether or not objects roughness are enabled for the G buffer.
  69872. */
  69873. set enableReflectivity(enable: boolean);
  69874. /**
  69875. * Gets the scene associated with the buffer.
  69876. */
  69877. get scene(): Scene;
  69878. /**
  69879. * Gets the ratio used by the buffer during its creation.
  69880. * How big is the buffer related to the main canvas.
  69881. */
  69882. get ratio(): number;
  69883. /** @hidden */
  69884. static _SceneComponentInitialization: (scene: Scene) => void;
  69885. /**
  69886. * Creates a new G Buffer for the scene
  69887. * @param scene The scene the buffer belongs to
  69888. * @param ratio How big is the buffer related to the main canvas.
  69889. */
  69890. constructor(scene: Scene, ratio?: number);
  69891. /**
  69892. * Checks wether everything is ready to render a submesh to the G buffer.
  69893. * @param subMesh the submesh to check readiness for
  69894. * @param useInstances is the mesh drawn using instance or not
  69895. * @returns true if ready otherwise false
  69896. */
  69897. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69898. /**
  69899. * Gets the current underlying G Buffer.
  69900. * @returns the buffer
  69901. */
  69902. getGBuffer(): MultiRenderTarget;
  69903. /**
  69904. * Gets the number of samples used to render the buffer (anti aliasing).
  69905. */
  69906. get samples(): number;
  69907. /**
  69908. * Sets the number of samples used to render the buffer (anti aliasing).
  69909. */
  69910. set samples(value: number);
  69911. /**
  69912. * Disposes the renderer and frees up associated resources.
  69913. */
  69914. dispose(): void;
  69915. protected _createRenderTargets(): void;
  69916. private _copyBonesTransformationMatrices;
  69917. }
  69918. }
  69919. declare module BABYLON {
  69920. interface Scene {
  69921. /** @hidden (Backing field) */
  69922. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69923. /**
  69924. * Gets or Sets the current geometry buffer associated to the scene.
  69925. */
  69926. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69927. /**
  69928. * Enables a GeometryBufferRender and associates it with the scene
  69929. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69930. * @returns the GeometryBufferRenderer
  69931. */
  69932. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69933. /**
  69934. * Disables the GeometryBufferRender associated with the scene
  69935. */
  69936. disableGeometryBufferRenderer(): void;
  69937. }
  69938. /**
  69939. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69940. * in several rendering techniques.
  69941. */
  69942. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69943. /**
  69944. * The component name helpful to identify the component in the list of scene components.
  69945. */
  69946. readonly name: string;
  69947. /**
  69948. * The scene the component belongs to.
  69949. */
  69950. scene: Scene;
  69951. /**
  69952. * Creates a new instance of the component for the given scene
  69953. * @param scene Defines the scene to register the component in
  69954. */
  69955. constructor(scene: Scene);
  69956. /**
  69957. * Registers the component in a given scene
  69958. */
  69959. register(): void;
  69960. /**
  69961. * Rebuilds the elements related to this component in case of
  69962. * context lost for instance.
  69963. */
  69964. rebuild(): void;
  69965. /**
  69966. * Disposes the component and the associated ressources
  69967. */
  69968. dispose(): void;
  69969. private _gatherRenderTargets;
  69970. }
  69971. }
  69972. declare module BABYLON {
  69973. /** @hidden */
  69974. export var motionBlurPixelShader: {
  69975. name: string;
  69976. shader: string;
  69977. };
  69978. }
  69979. declare module BABYLON {
  69980. /**
  69981. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69982. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69983. * As an example, all you have to do is to create the post-process:
  69984. * var mb = new BABYLON.MotionBlurPostProcess(
  69985. * 'mb', // The name of the effect.
  69986. * scene, // The scene containing the objects to blur according to their velocity.
  69987. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69988. * camera // The camera to apply the render pass to.
  69989. * );
  69990. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69991. */
  69992. export class MotionBlurPostProcess extends PostProcess {
  69993. /**
  69994. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69995. */
  69996. motionStrength: number;
  69997. /**
  69998. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69999. */
  70000. get motionBlurSamples(): number;
  70001. /**
  70002. * Sets the number of iterations to be used for motion blur quality
  70003. */
  70004. set motionBlurSamples(samples: number);
  70005. private _motionBlurSamples;
  70006. private _geometryBufferRenderer;
  70007. /**
  70008. * Gets a string identifying the name of the class
  70009. * @returns "MotionBlurPostProcess" string
  70010. */
  70011. getClassName(): string;
  70012. /**
  70013. * Creates a new instance MotionBlurPostProcess
  70014. * @param name The name of the effect.
  70015. * @param scene The scene containing the objects to blur according to their velocity.
  70016. * @param options The required width/height ratio to downsize to before computing the render pass.
  70017. * @param camera The camera to apply the render pass to.
  70018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70019. * @param engine The engine which the post process will be applied. (default: current engine)
  70020. * @param reusable If the post process can be reused on the same frame. (default: false)
  70021. * @param textureType Type of textures used when performing the post process. (default: 0)
  70022. * @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)
  70023. */
  70024. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70025. /**
  70026. * Excludes the given skinned mesh from computing bones velocities.
  70027. * 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.
  70028. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70029. */
  70030. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70031. /**
  70032. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70033. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70034. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70035. */
  70036. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70037. /**
  70038. * Disposes the post process.
  70039. * @param camera The camera to dispose the post process on.
  70040. */
  70041. dispose(camera?: Camera): void;
  70042. /** @hidden */
  70043. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70044. }
  70045. }
  70046. declare module BABYLON {
  70047. /** @hidden */
  70048. export var refractionPixelShader: {
  70049. name: string;
  70050. shader: string;
  70051. };
  70052. }
  70053. declare module BABYLON {
  70054. /**
  70055. * Post process which applies a refractin texture
  70056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70057. */
  70058. export class RefractionPostProcess extends PostProcess {
  70059. private _refTexture;
  70060. private _ownRefractionTexture;
  70061. /** the base color of the refraction (used to taint the rendering) */
  70062. color: Color3;
  70063. /** simulated refraction depth */
  70064. depth: number;
  70065. /** the coefficient of the base color (0 to remove base color tainting) */
  70066. colorLevel: number;
  70067. /** Gets the url used to load the refraction texture */
  70068. refractionTextureUrl: string;
  70069. /**
  70070. * Gets or sets the refraction texture
  70071. * Please note that you are responsible for disposing the texture if you set it manually
  70072. */
  70073. get refractionTexture(): Texture;
  70074. set refractionTexture(value: Texture);
  70075. /**
  70076. * Gets a string identifying the name of the class
  70077. * @returns "RefractionPostProcess" string
  70078. */
  70079. getClassName(): string;
  70080. /**
  70081. * Initializes the RefractionPostProcess
  70082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70083. * @param name The name of the effect.
  70084. * @param refractionTextureUrl Url of the refraction texture to use
  70085. * @param color the base color of the refraction (used to taint the rendering)
  70086. * @param depth simulated refraction depth
  70087. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70088. * @param camera The camera to apply the render pass to.
  70089. * @param options The required width/height ratio to downsize to before computing the render pass.
  70090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70091. * @param engine The engine which the post process will be applied. (default: current engine)
  70092. * @param reusable If the post process can be reused on the same frame. (default: false)
  70093. */
  70094. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70095. /**
  70096. * Disposes of the post process
  70097. * @param camera Camera to dispose post process on
  70098. */
  70099. dispose(camera: Camera): void;
  70100. /** @hidden */
  70101. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70102. }
  70103. }
  70104. declare module BABYLON {
  70105. /** @hidden */
  70106. export var sharpenPixelShader: {
  70107. name: string;
  70108. shader: string;
  70109. };
  70110. }
  70111. declare module BABYLON {
  70112. /**
  70113. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70114. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70115. */
  70116. export class SharpenPostProcess extends PostProcess {
  70117. /**
  70118. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70119. */
  70120. colorAmount: number;
  70121. /**
  70122. * How much sharpness should be applied (default: 0.3)
  70123. */
  70124. edgeAmount: number;
  70125. /**
  70126. * Gets a string identifying the name of the class
  70127. * @returns "SharpenPostProcess" string
  70128. */
  70129. getClassName(): string;
  70130. /**
  70131. * Creates a new instance ConvolutionPostProcess
  70132. * @param name The name of the effect.
  70133. * @param options The required width/height ratio to downsize to before computing the render pass.
  70134. * @param camera The camera to apply the render pass to.
  70135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70136. * @param engine The engine which the post process will be applied. (default: current engine)
  70137. * @param reusable If the post process can be reused on the same frame. (default: false)
  70138. * @param textureType Type of textures used when performing the post process. (default: 0)
  70139. * @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)
  70140. */
  70141. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70142. /** @hidden */
  70143. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70144. }
  70145. }
  70146. declare module BABYLON {
  70147. /**
  70148. * PostProcessRenderPipeline
  70149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70150. */
  70151. export class PostProcessRenderPipeline {
  70152. private engine;
  70153. private _renderEffects;
  70154. private _renderEffectsForIsolatedPass;
  70155. /**
  70156. * List of inspectable custom properties (used by the Inspector)
  70157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70158. */
  70159. inspectableCustomProperties: IInspectable[];
  70160. /**
  70161. * @hidden
  70162. */
  70163. protected _cameras: Camera[];
  70164. /** @hidden */
  70165. _name: string;
  70166. /**
  70167. * Gets pipeline name
  70168. */
  70169. get name(): string;
  70170. /** Gets the list of attached cameras */
  70171. get cameras(): Camera[];
  70172. /**
  70173. * Initializes a PostProcessRenderPipeline
  70174. * @param engine engine to add the pipeline to
  70175. * @param name name of the pipeline
  70176. */
  70177. constructor(engine: Engine, name: string);
  70178. /**
  70179. * Gets the class name
  70180. * @returns "PostProcessRenderPipeline"
  70181. */
  70182. getClassName(): string;
  70183. /**
  70184. * If all the render effects in the pipeline are supported
  70185. */
  70186. get isSupported(): boolean;
  70187. /**
  70188. * Adds an effect to the pipeline
  70189. * @param renderEffect the effect to add
  70190. */
  70191. addEffect(renderEffect: PostProcessRenderEffect): void;
  70192. /** @hidden */
  70193. _rebuild(): void;
  70194. /** @hidden */
  70195. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70196. /** @hidden */
  70197. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70198. /** @hidden */
  70199. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70200. /** @hidden */
  70201. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70202. /** @hidden */
  70203. _attachCameras(cameras: Camera, unique: boolean): void;
  70204. /** @hidden */
  70205. _attachCameras(cameras: Camera[], unique: boolean): void;
  70206. /** @hidden */
  70207. _detachCameras(cameras: Camera): void;
  70208. /** @hidden */
  70209. _detachCameras(cameras: Nullable<Camera[]>): void;
  70210. /** @hidden */
  70211. _update(): void;
  70212. /** @hidden */
  70213. _reset(): void;
  70214. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70215. /**
  70216. * Sets the required values to the prepass renderer.
  70217. * @param prePassRenderer defines the prepass renderer to setup.
  70218. * @returns true if the pre pass is needed.
  70219. */
  70220. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70221. /**
  70222. * Disposes of the pipeline
  70223. */
  70224. dispose(): void;
  70225. }
  70226. }
  70227. declare module BABYLON {
  70228. /**
  70229. * PostProcessRenderPipelineManager class
  70230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70231. */
  70232. export class PostProcessRenderPipelineManager {
  70233. private _renderPipelines;
  70234. /**
  70235. * Initializes a PostProcessRenderPipelineManager
  70236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70237. */
  70238. constructor();
  70239. /**
  70240. * Gets the list of supported render pipelines
  70241. */
  70242. get supportedPipelines(): PostProcessRenderPipeline[];
  70243. /**
  70244. * Adds a pipeline to the manager
  70245. * @param renderPipeline The pipeline to add
  70246. */
  70247. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70248. /**
  70249. * Attaches a camera to the pipeline
  70250. * @param renderPipelineName The name of the pipeline to attach to
  70251. * @param cameras the camera to attach
  70252. * @param unique if the camera can be attached multiple times to the pipeline
  70253. */
  70254. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70255. /**
  70256. * Detaches a camera from the pipeline
  70257. * @param renderPipelineName The name of the pipeline to detach from
  70258. * @param cameras the camera to detach
  70259. */
  70260. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70261. /**
  70262. * Enables an effect by name on a pipeline
  70263. * @param renderPipelineName the name of the pipeline to enable the effect in
  70264. * @param renderEffectName the name of the effect to enable
  70265. * @param cameras the cameras that the effect should be enabled on
  70266. */
  70267. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70268. /**
  70269. * Disables an effect by name on a pipeline
  70270. * @param renderPipelineName the name of the pipeline to disable the effect in
  70271. * @param renderEffectName the name of the effect to disable
  70272. * @param cameras the cameras that the effect should be disabled on
  70273. */
  70274. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70275. /**
  70276. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70277. */
  70278. update(): void;
  70279. /** @hidden */
  70280. _rebuild(): void;
  70281. /**
  70282. * Disposes of the manager and pipelines
  70283. */
  70284. dispose(): void;
  70285. }
  70286. }
  70287. declare module BABYLON {
  70288. interface Scene {
  70289. /** @hidden (Backing field) */
  70290. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70291. /**
  70292. * Gets the postprocess render pipeline manager
  70293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70294. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70295. */
  70296. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70297. }
  70298. /**
  70299. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70300. */
  70301. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70302. /**
  70303. * The component name helpfull to identify the component in the list of scene components.
  70304. */
  70305. readonly name: string;
  70306. /**
  70307. * The scene the component belongs to.
  70308. */
  70309. scene: Scene;
  70310. /**
  70311. * Creates a new instance of the component for the given scene
  70312. * @param scene Defines the scene to register the component in
  70313. */
  70314. constructor(scene: Scene);
  70315. /**
  70316. * Registers the component in a given scene
  70317. */
  70318. register(): void;
  70319. /**
  70320. * Rebuilds the elements related to this component in case of
  70321. * context lost for instance.
  70322. */
  70323. rebuild(): void;
  70324. /**
  70325. * Disposes the component and the associated ressources
  70326. */
  70327. dispose(): void;
  70328. private _gatherRenderTargets;
  70329. }
  70330. }
  70331. declare module BABYLON {
  70332. /**
  70333. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70334. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70335. */
  70336. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70337. private _scene;
  70338. private _camerasToBeAttached;
  70339. /**
  70340. * ID of the sharpen post process,
  70341. */
  70342. private readonly SharpenPostProcessId;
  70343. /**
  70344. * @ignore
  70345. * ID of the image processing post process;
  70346. */
  70347. readonly ImageProcessingPostProcessId: string;
  70348. /**
  70349. * @ignore
  70350. * ID of the Fast Approximate Anti-Aliasing post process;
  70351. */
  70352. readonly FxaaPostProcessId: string;
  70353. /**
  70354. * ID of the chromatic aberration post process,
  70355. */
  70356. private readonly ChromaticAberrationPostProcessId;
  70357. /**
  70358. * ID of the grain post process
  70359. */
  70360. private readonly GrainPostProcessId;
  70361. /**
  70362. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70363. */
  70364. sharpen: SharpenPostProcess;
  70365. private _sharpenEffect;
  70366. private bloom;
  70367. /**
  70368. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70369. */
  70370. depthOfField: DepthOfFieldEffect;
  70371. /**
  70372. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70373. */
  70374. fxaa: FxaaPostProcess;
  70375. /**
  70376. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70377. */
  70378. imageProcessing: ImageProcessingPostProcess;
  70379. /**
  70380. * Chromatic aberration post process which will shift rgb colors in the image
  70381. */
  70382. chromaticAberration: ChromaticAberrationPostProcess;
  70383. private _chromaticAberrationEffect;
  70384. /**
  70385. * Grain post process which add noise to the image
  70386. */
  70387. grain: GrainPostProcess;
  70388. private _grainEffect;
  70389. /**
  70390. * Glow post process which adds a glow to emissive areas of the image
  70391. */
  70392. private _glowLayer;
  70393. /**
  70394. * Animations which can be used to tweak settings over a period of time
  70395. */
  70396. animations: Animation[];
  70397. private _imageProcessingConfigurationObserver;
  70398. private _sharpenEnabled;
  70399. private _bloomEnabled;
  70400. private _depthOfFieldEnabled;
  70401. private _depthOfFieldBlurLevel;
  70402. private _fxaaEnabled;
  70403. private _imageProcessingEnabled;
  70404. private _defaultPipelineTextureType;
  70405. private _bloomScale;
  70406. private _chromaticAberrationEnabled;
  70407. private _grainEnabled;
  70408. private _buildAllowed;
  70409. /**
  70410. * Gets active scene
  70411. */
  70412. get scene(): Scene;
  70413. /**
  70414. * Enable or disable the sharpen process from the pipeline
  70415. */
  70416. set sharpenEnabled(enabled: boolean);
  70417. get sharpenEnabled(): boolean;
  70418. private _resizeObserver;
  70419. private _hardwareScaleLevel;
  70420. private _bloomKernel;
  70421. /**
  70422. * Specifies the size of the bloom blur kernel, relative to the final output size
  70423. */
  70424. get bloomKernel(): number;
  70425. set bloomKernel(value: number);
  70426. /**
  70427. * Specifies the weight of the bloom in the final rendering
  70428. */
  70429. private _bloomWeight;
  70430. /**
  70431. * Specifies the luma threshold for the area that will be blurred by the bloom
  70432. */
  70433. private _bloomThreshold;
  70434. private _hdr;
  70435. /**
  70436. * The strength of the bloom.
  70437. */
  70438. set bloomWeight(value: number);
  70439. get bloomWeight(): number;
  70440. /**
  70441. * The strength of the bloom.
  70442. */
  70443. set bloomThreshold(value: number);
  70444. get bloomThreshold(): number;
  70445. /**
  70446. * The scale of the bloom, lower value will provide better performance.
  70447. */
  70448. set bloomScale(value: number);
  70449. get bloomScale(): number;
  70450. /**
  70451. * Enable or disable the bloom from the pipeline
  70452. */
  70453. set bloomEnabled(enabled: boolean);
  70454. get bloomEnabled(): boolean;
  70455. private _rebuildBloom;
  70456. /**
  70457. * If the depth of field is enabled.
  70458. */
  70459. get depthOfFieldEnabled(): boolean;
  70460. set depthOfFieldEnabled(enabled: boolean);
  70461. /**
  70462. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70463. */
  70464. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70465. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70466. /**
  70467. * If the anti aliasing is enabled.
  70468. */
  70469. set fxaaEnabled(enabled: boolean);
  70470. get fxaaEnabled(): boolean;
  70471. private _samples;
  70472. /**
  70473. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70474. */
  70475. set samples(sampleCount: number);
  70476. get samples(): number;
  70477. /**
  70478. * If image processing is enabled.
  70479. */
  70480. set imageProcessingEnabled(enabled: boolean);
  70481. get imageProcessingEnabled(): boolean;
  70482. /**
  70483. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70484. */
  70485. set glowLayerEnabled(enabled: boolean);
  70486. get glowLayerEnabled(): boolean;
  70487. /**
  70488. * Gets the glow layer (or null if not defined)
  70489. */
  70490. get glowLayer(): Nullable<GlowLayer>;
  70491. /**
  70492. * Enable or disable the chromaticAberration process from the pipeline
  70493. */
  70494. set chromaticAberrationEnabled(enabled: boolean);
  70495. get chromaticAberrationEnabled(): boolean;
  70496. /**
  70497. * Enable or disable the grain process from the pipeline
  70498. */
  70499. set grainEnabled(enabled: boolean);
  70500. get grainEnabled(): boolean;
  70501. /**
  70502. * @constructor
  70503. * @param name - The rendering pipeline name (default: "")
  70504. * @param hdr - If high dynamic range textures should be used (default: true)
  70505. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70506. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70507. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70508. */
  70509. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70510. /**
  70511. * Get the class name
  70512. * @returns "DefaultRenderingPipeline"
  70513. */
  70514. getClassName(): string;
  70515. /**
  70516. * Force the compilation of the entire pipeline.
  70517. */
  70518. prepare(): void;
  70519. private _hasCleared;
  70520. private _prevPostProcess;
  70521. private _prevPrevPostProcess;
  70522. private _setAutoClearAndTextureSharing;
  70523. private _depthOfFieldSceneObserver;
  70524. private _buildPipeline;
  70525. private _disposePostProcesses;
  70526. /**
  70527. * Adds a camera to the pipeline
  70528. * @param camera the camera to be added
  70529. */
  70530. addCamera(camera: Camera): void;
  70531. /**
  70532. * Removes a camera from the pipeline
  70533. * @param camera the camera to remove
  70534. */
  70535. removeCamera(camera: Camera): void;
  70536. /**
  70537. * Dispose of the pipeline and stop all post processes
  70538. */
  70539. dispose(): void;
  70540. /**
  70541. * Serialize the rendering pipeline (Used when exporting)
  70542. * @returns the serialized object
  70543. */
  70544. serialize(): any;
  70545. /**
  70546. * Parse the serialized pipeline
  70547. * @param source Source pipeline.
  70548. * @param scene The scene to load the pipeline to.
  70549. * @param rootUrl The URL of the serialized pipeline.
  70550. * @returns An instantiated pipeline from the serialized object.
  70551. */
  70552. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70553. }
  70554. }
  70555. declare module BABYLON {
  70556. /** @hidden */
  70557. export var lensHighlightsPixelShader: {
  70558. name: string;
  70559. shader: string;
  70560. };
  70561. }
  70562. declare module BABYLON {
  70563. /** @hidden */
  70564. export var depthOfFieldPixelShader: {
  70565. name: string;
  70566. shader: string;
  70567. };
  70568. }
  70569. declare module BABYLON {
  70570. /**
  70571. * BABYLON.JS Chromatic Aberration GLSL Shader
  70572. * Author: Olivier Guyot
  70573. * Separates very slightly R, G and B colors on the edges of the screen
  70574. * Inspired by Francois Tarlier & Martins Upitis
  70575. */
  70576. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70577. /**
  70578. * @ignore
  70579. * The chromatic aberration PostProcess id in the pipeline
  70580. */
  70581. LensChromaticAberrationEffect: string;
  70582. /**
  70583. * @ignore
  70584. * The highlights enhancing PostProcess id in the pipeline
  70585. */
  70586. HighlightsEnhancingEffect: string;
  70587. /**
  70588. * @ignore
  70589. * The depth-of-field PostProcess id in the pipeline
  70590. */
  70591. LensDepthOfFieldEffect: string;
  70592. private _scene;
  70593. private _depthTexture;
  70594. private _grainTexture;
  70595. private _chromaticAberrationPostProcess;
  70596. private _highlightsPostProcess;
  70597. private _depthOfFieldPostProcess;
  70598. private _edgeBlur;
  70599. private _grainAmount;
  70600. private _chromaticAberration;
  70601. private _distortion;
  70602. private _highlightsGain;
  70603. private _highlightsThreshold;
  70604. private _dofDistance;
  70605. private _dofAperture;
  70606. private _dofDarken;
  70607. private _dofPentagon;
  70608. private _blurNoise;
  70609. /**
  70610. * @constructor
  70611. *
  70612. * Effect parameters are as follow:
  70613. * {
  70614. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70615. * edge_blur: number; // from 0 to x (1 for realism)
  70616. * distortion: number; // from 0 to x (1 for realism)
  70617. * grain_amount: number; // from 0 to 1
  70618. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70619. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70620. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70621. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70622. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70623. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70624. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70625. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70626. * }
  70627. * Note: if an effect parameter is unset, effect is disabled
  70628. *
  70629. * @param name The rendering pipeline name
  70630. * @param parameters - An object containing all parameters (see above)
  70631. * @param scene The scene linked to this pipeline
  70632. * @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)
  70633. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70634. */
  70635. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70636. /**
  70637. * Get the class name
  70638. * @returns "LensRenderingPipeline"
  70639. */
  70640. getClassName(): string;
  70641. /**
  70642. * Gets associated scene
  70643. */
  70644. get scene(): Scene;
  70645. /**
  70646. * Gets or sets the edge blur
  70647. */
  70648. get edgeBlur(): number;
  70649. set edgeBlur(value: number);
  70650. /**
  70651. * Gets or sets the grain amount
  70652. */
  70653. get grainAmount(): number;
  70654. set grainAmount(value: number);
  70655. /**
  70656. * Gets or sets the chromatic aberration amount
  70657. */
  70658. get chromaticAberration(): number;
  70659. set chromaticAberration(value: number);
  70660. /**
  70661. * Gets or sets the depth of field aperture
  70662. */
  70663. get dofAperture(): number;
  70664. set dofAperture(value: number);
  70665. /**
  70666. * Gets or sets the edge distortion
  70667. */
  70668. get edgeDistortion(): number;
  70669. set edgeDistortion(value: number);
  70670. /**
  70671. * Gets or sets the depth of field distortion
  70672. */
  70673. get dofDistortion(): number;
  70674. set dofDistortion(value: number);
  70675. /**
  70676. * Gets or sets the darken out of focus amount
  70677. */
  70678. get darkenOutOfFocus(): number;
  70679. set darkenOutOfFocus(value: number);
  70680. /**
  70681. * Gets or sets a boolean indicating if blur noise is enabled
  70682. */
  70683. get blurNoise(): boolean;
  70684. set blurNoise(value: boolean);
  70685. /**
  70686. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70687. */
  70688. get pentagonBokeh(): boolean;
  70689. set pentagonBokeh(value: boolean);
  70690. /**
  70691. * Gets or sets the highlight grain amount
  70692. */
  70693. get highlightsGain(): number;
  70694. set highlightsGain(value: number);
  70695. /**
  70696. * Gets or sets the highlight threshold
  70697. */
  70698. get highlightsThreshold(): number;
  70699. set highlightsThreshold(value: number);
  70700. /**
  70701. * Sets the amount of blur at the edges
  70702. * @param amount blur amount
  70703. */
  70704. setEdgeBlur(amount: number): void;
  70705. /**
  70706. * Sets edge blur to 0
  70707. */
  70708. disableEdgeBlur(): void;
  70709. /**
  70710. * Sets the amout of grain
  70711. * @param amount Amount of grain
  70712. */
  70713. setGrainAmount(amount: number): void;
  70714. /**
  70715. * Set grain amount to 0
  70716. */
  70717. disableGrain(): void;
  70718. /**
  70719. * Sets the chromatic aberration amount
  70720. * @param amount amount of chromatic aberration
  70721. */
  70722. setChromaticAberration(amount: number): void;
  70723. /**
  70724. * Sets chromatic aberration amount to 0
  70725. */
  70726. disableChromaticAberration(): void;
  70727. /**
  70728. * Sets the EdgeDistortion amount
  70729. * @param amount amount of EdgeDistortion
  70730. */
  70731. setEdgeDistortion(amount: number): void;
  70732. /**
  70733. * Sets edge distortion to 0
  70734. */
  70735. disableEdgeDistortion(): void;
  70736. /**
  70737. * Sets the FocusDistance amount
  70738. * @param amount amount of FocusDistance
  70739. */
  70740. setFocusDistance(amount: number): void;
  70741. /**
  70742. * Disables depth of field
  70743. */
  70744. disableDepthOfField(): void;
  70745. /**
  70746. * Sets the Aperture amount
  70747. * @param amount amount of Aperture
  70748. */
  70749. setAperture(amount: number): void;
  70750. /**
  70751. * Sets the DarkenOutOfFocus amount
  70752. * @param amount amount of DarkenOutOfFocus
  70753. */
  70754. setDarkenOutOfFocus(amount: number): void;
  70755. private _pentagonBokehIsEnabled;
  70756. /**
  70757. * Creates a pentagon bokeh effect
  70758. */
  70759. enablePentagonBokeh(): void;
  70760. /**
  70761. * Disables the pentagon bokeh effect
  70762. */
  70763. disablePentagonBokeh(): void;
  70764. /**
  70765. * Enables noise blur
  70766. */
  70767. enableNoiseBlur(): void;
  70768. /**
  70769. * Disables noise blur
  70770. */
  70771. disableNoiseBlur(): void;
  70772. /**
  70773. * Sets the HighlightsGain amount
  70774. * @param amount amount of HighlightsGain
  70775. */
  70776. setHighlightsGain(amount: number): void;
  70777. /**
  70778. * Sets the HighlightsThreshold amount
  70779. * @param amount amount of HighlightsThreshold
  70780. */
  70781. setHighlightsThreshold(amount: number): void;
  70782. /**
  70783. * Disables highlights
  70784. */
  70785. disableHighlights(): void;
  70786. /**
  70787. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70788. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70789. */
  70790. dispose(disableDepthRender?: boolean): void;
  70791. private _createChromaticAberrationPostProcess;
  70792. private _createHighlightsPostProcess;
  70793. private _createDepthOfFieldPostProcess;
  70794. private _createGrainTexture;
  70795. }
  70796. }
  70797. declare module BABYLON {
  70798. /** @hidden */
  70799. export var ssao2PixelShader: {
  70800. name: string;
  70801. shader: string;
  70802. };
  70803. }
  70804. declare module BABYLON {
  70805. /** @hidden */
  70806. export var ssaoCombinePixelShader: {
  70807. name: string;
  70808. shader: string;
  70809. };
  70810. }
  70811. declare module BABYLON {
  70812. /**
  70813. * Render pipeline to produce ssao effect
  70814. */
  70815. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70816. /**
  70817. * @ignore
  70818. * The PassPostProcess id in the pipeline that contains the original scene color
  70819. */
  70820. SSAOOriginalSceneColorEffect: string;
  70821. /**
  70822. * @ignore
  70823. * The SSAO PostProcess id in the pipeline
  70824. */
  70825. SSAORenderEffect: string;
  70826. /**
  70827. * @ignore
  70828. * The horizontal blur PostProcess id in the pipeline
  70829. */
  70830. SSAOBlurHRenderEffect: string;
  70831. /**
  70832. * @ignore
  70833. * The vertical blur PostProcess id in the pipeline
  70834. */
  70835. SSAOBlurVRenderEffect: string;
  70836. /**
  70837. * @ignore
  70838. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70839. */
  70840. SSAOCombineRenderEffect: string;
  70841. /**
  70842. * The output strength of the SSAO post-process. Default value is 1.0.
  70843. */
  70844. totalStrength: number;
  70845. /**
  70846. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70847. */
  70848. maxZ: number;
  70849. /**
  70850. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70851. */
  70852. minZAspect: number;
  70853. private _samples;
  70854. /**
  70855. * Number of samples used for the SSAO calculations. Default value is 8
  70856. */
  70857. set samples(n: number);
  70858. get samples(): number;
  70859. private _textureSamples;
  70860. /**
  70861. * Number of samples to use for antialiasing
  70862. */
  70863. set textureSamples(n: number);
  70864. get textureSamples(): number;
  70865. /**
  70866. * Force rendering the geometry through geometry buffer
  70867. */
  70868. private _forceGeometryBuffer;
  70869. /**
  70870. * Ratio object used for SSAO ratio and blur ratio
  70871. */
  70872. private _ratio;
  70873. /**
  70874. * Dynamically generated sphere sampler.
  70875. */
  70876. private _sampleSphere;
  70877. /**
  70878. * Blur filter offsets
  70879. */
  70880. private _samplerOffsets;
  70881. private _expensiveBlur;
  70882. /**
  70883. * If bilateral blur should be used
  70884. */
  70885. set expensiveBlur(b: boolean);
  70886. get expensiveBlur(): boolean;
  70887. /**
  70888. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70889. */
  70890. radius: number;
  70891. /**
  70892. * The base color of the SSAO post-process
  70893. * The final result is "base + ssao" between [0, 1]
  70894. */
  70895. base: number;
  70896. /**
  70897. * Support test.
  70898. */
  70899. static get IsSupported(): boolean;
  70900. private _scene;
  70901. private _randomTexture;
  70902. private _originalColorPostProcess;
  70903. private _ssaoPostProcess;
  70904. private _blurHPostProcess;
  70905. private _blurVPostProcess;
  70906. private _ssaoCombinePostProcess;
  70907. private _prePassRenderer;
  70908. /**
  70909. * Gets active scene
  70910. */
  70911. get scene(): Scene;
  70912. /**
  70913. * @constructor
  70914. * @param name The rendering pipeline name
  70915. * @param scene The scene linked to this pipeline
  70916. * @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 }
  70917. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70918. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70919. */
  70920. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70921. /**
  70922. * Get the class name
  70923. * @returns "SSAO2RenderingPipeline"
  70924. */
  70925. getClassName(): string;
  70926. /**
  70927. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70928. */
  70929. dispose(disableGeometryBufferRenderer?: boolean): void;
  70930. private _createBlurPostProcess;
  70931. /** @hidden */
  70932. _rebuild(): void;
  70933. private _bits;
  70934. private _radicalInverse_VdC;
  70935. private _hammersley;
  70936. private _hemisphereSample_uniform;
  70937. private _generateHemisphere;
  70938. private _getDefinesForSSAO;
  70939. private _createSSAOPostProcess;
  70940. private _createSSAOCombinePostProcess;
  70941. private _createRandomTexture;
  70942. /**
  70943. * Serialize the rendering pipeline (Used when exporting)
  70944. * @returns the serialized object
  70945. */
  70946. serialize(): any;
  70947. /**
  70948. * Parse the serialized pipeline
  70949. * @param source Source pipeline.
  70950. * @param scene The scene to load the pipeline to.
  70951. * @param rootUrl The URL of the serialized pipeline.
  70952. * @returns An instantiated pipeline from the serialized object.
  70953. */
  70954. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70955. /**
  70956. * Sets the required values to the prepass renderer.
  70957. * @param prePassRenderer defines the prepass renderer to setup
  70958. * @returns true if the pre pass is needed.
  70959. */
  70960. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70961. }
  70962. }
  70963. declare module BABYLON {
  70964. /** @hidden */
  70965. export var ssaoPixelShader: {
  70966. name: string;
  70967. shader: string;
  70968. };
  70969. }
  70970. declare module BABYLON {
  70971. /**
  70972. * Render pipeline to produce ssao effect
  70973. */
  70974. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70975. /**
  70976. * @ignore
  70977. * The PassPostProcess id in the pipeline that contains the original scene color
  70978. */
  70979. SSAOOriginalSceneColorEffect: string;
  70980. /**
  70981. * @ignore
  70982. * The SSAO PostProcess id in the pipeline
  70983. */
  70984. SSAORenderEffect: string;
  70985. /**
  70986. * @ignore
  70987. * The horizontal blur PostProcess id in the pipeline
  70988. */
  70989. SSAOBlurHRenderEffect: string;
  70990. /**
  70991. * @ignore
  70992. * The vertical blur PostProcess id in the pipeline
  70993. */
  70994. SSAOBlurVRenderEffect: string;
  70995. /**
  70996. * @ignore
  70997. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70998. */
  70999. SSAOCombineRenderEffect: string;
  71000. /**
  71001. * The output strength of the SSAO post-process. Default value is 1.0.
  71002. */
  71003. totalStrength: number;
  71004. /**
  71005. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71006. */
  71007. radius: number;
  71008. /**
  71009. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71010. * Must not be equal to fallOff and superior to fallOff.
  71011. * Default value is 0.0075
  71012. */
  71013. area: number;
  71014. /**
  71015. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71016. * Must not be equal to area and inferior to area.
  71017. * Default value is 0.000001
  71018. */
  71019. fallOff: number;
  71020. /**
  71021. * The base color of the SSAO post-process
  71022. * The final result is "base + ssao" between [0, 1]
  71023. */
  71024. base: number;
  71025. private _scene;
  71026. private _depthTexture;
  71027. private _randomTexture;
  71028. private _originalColorPostProcess;
  71029. private _ssaoPostProcess;
  71030. private _blurHPostProcess;
  71031. private _blurVPostProcess;
  71032. private _ssaoCombinePostProcess;
  71033. private _firstUpdate;
  71034. /**
  71035. * Gets active scene
  71036. */
  71037. get scene(): Scene;
  71038. /**
  71039. * @constructor
  71040. * @param name - The rendering pipeline name
  71041. * @param scene - The scene linked to this pipeline
  71042. * @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 }
  71043. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71044. */
  71045. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71046. /**
  71047. * Get the class name
  71048. * @returns "SSAORenderingPipeline"
  71049. */
  71050. getClassName(): string;
  71051. /**
  71052. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71053. */
  71054. dispose(disableDepthRender?: boolean): void;
  71055. private _createBlurPostProcess;
  71056. /** @hidden */
  71057. _rebuild(): void;
  71058. private _createSSAOPostProcess;
  71059. private _createSSAOCombinePostProcess;
  71060. private _createRandomTexture;
  71061. }
  71062. }
  71063. declare module BABYLON {
  71064. /** @hidden */
  71065. export var screenSpaceReflectionPixelShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module BABYLON {
  71071. /**
  71072. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71073. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71074. */
  71075. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71076. /**
  71077. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71078. */
  71079. threshold: number;
  71080. /**
  71081. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71082. */
  71083. strength: number;
  71084. /**
  71085. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71086. */
  71087. reflectionSpecularFalloffExponent: number;
  71088. /**
  71089. * 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]
  71090. */
  71091. step: number;
  71092. /**
  71093. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71094. */
  71095. roughnessFactor: number;
  71096. private _geometryBufferRenderer;
  71097. private _enableSmoothReflections;
  71098. private _reflectionSamples;
  71099. private _smoothSteps;
  71100. /**
  71101. * Gets a string identifying the name of the class
  71102. * @returns "ScreenSpaceReflectionPostProcess" string
  71103. */
  71104. getClassName(): string;
  71105. /**
  71106. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71107. * @param name The name of the effect.
  71108. * @param scene The scene containing the objects to calculate reflections.
  71109. * @param options The required width/height ratio to downsize to before computing the render pass.
  71110. * @param camera The camera to apply the render pass to.
  71111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71112. * @param engine The engine which the post process will be applied. (default: current engine)
  71113. * @param reusable If the post process can be reused on the same frame. (default: false)
  71114. * @param textureType Type of textures used when performing the post process. (default: 0)
  71115. * @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)
  71116. */
  71117. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71118. /**
  71119. * Gets wether or not smoothing reflections is enabled.
  71120. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71121. */
  71122. get enableSmoothReflections(): boolean;
  71123. /**
  71124. * Sets wether or not smoothing reflections is enabled.
  71125. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71126. */
  71127. set enableSmoothReflections(enabled: boolean);
  71128. /**
  71129. * Gets the number of samples taken while computing reflections. More samples count is high,
  71130. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71131. */
  71132. get reflectionSamples(): number;
  71133. /**
  71134. * Sets the number of samples taken while computing reflections. More samples count is high,
  71135. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71136. */
  71137. set reflectionSamples(samples: number);
  71138. /**
  71139. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71140. * more the post-process will require GPU power and can generate a drop in FPS.
  71141. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71142. */
  71143. get smoothSteps(): number;
  71144. set smoothSteps(steps: number);
  71145. private _updateEffectDefines;
  71146. /** @hidden */
  71147. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71148. }
  71149. }
  71150. declare module BABYLON {
  71151. /** @hidden */
  71152. export var standardPixelShader: {
  71153. name: string;
  71154. shader: string;
  71155. };
  71156. }
  71157. declare module BABYLON {
  71158. /**
  71159. * Standard rendering pipeline
  71160. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71161. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71162. */
  71163. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71164. /**
  71165. * Public members
  71166. */
  71167. /**
  71168. * Post-process which contains the original scene color before the pipeline applies all the effects
  71169. */
  71170. originalPostProcess: Nullable<PostProcess>;
  71171. /**
  71172. * Post-process used to down scale an image x4
  71173. */
  71174. downSampleX4PostProcess: Nullable<PostProcess>;
  71175. /**
  71176. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71177. */
  71178. brightPassPostProcess: Nullable<PostProcess>;
  71179. /**
  71180. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71181. */
  71182. blurHPostProcesses: PostProcess[];
  71183. /**
  71184. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71185. */
  71186. blurVPostProcesses: PostProcess[];
  71187. /**
  71188. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71189. */
  71190. textureAdderPostProcess: Nullable<PostProcess>;
  71191. /**
  71192. * Post-process used to create volumetric lighting effect
  71193. */
  71194. volumetricLightPostProcess: Nullable<PostProcess>;
  71195. /**
  71196. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71197. */
  71198. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71199. /**
  71200. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71201. */
  71202. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71203. /**
  71204. * Post-process used to merge the volumetric light effect and the real scene color
  71205. */
  71206. volumetricLightMergePostProces: Nullable<PostProcess>;
  71207. /**
  71208. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71209. */
  71210. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71211. /**
  71212. * Base post-process used to calculate the average luminance of the final image for HDR
  71213. */
  71214. luminancePostProcess: Nullable<PostProcess>;
  71215. /**
  71216. * Post-processes used to create down sample post-processes in order to get
  71217. * the average luminance of the final image for HDR
  71218. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71219. */
  71220. luminanceDownSamplePostProcesses: PostProcess[];
  71221. /**
  71222. * Post-process used to create a HDR effect (light adaptation)
  71223. */
  71224. hdrPostProcess: Nullable<PostProcess>;
  71225. /**
  71226. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71227. */
  71228. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71229. /**
  71230. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71231. */
  71232. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71233. /**
  71234. * Post-process used to merge the final HDR post-process and the real scene color
  71235. */
  71236. hdrFinalPostProcess: Nullable<PostProcess>;
  71237. /**
  71238. * Post-process used to create a lens flare effect
  71239. */
  71240. lensFlarePostProcess: Nullable<PostProcess>;
  71241. /**
  71242. * Post-process that merges the result of the lens flare post-process and the real scene color
  71243. */
  71244. lensFlareComposePostProcess: Nullable<PostProcess>;
  71245. /**
  71246. * Post-process used to create a motion blur effect
  71247. */
  71248. motionBlurPostProcess: Nullable<PostProcess>;
  71249. /**
  71250. * Post-process used to create a depth of field effect
  71251. */
  71252. depthOfFieldPostProcess: Nullable<PostProcess>;
  71253. /**
  71254. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71255. */
  71256. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71257. /**
  71258. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71259. */
  71260. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71261. /**
  71262. * Represents the brightness threshold in order to configure the illuminated surfaces
  71263. */
  71264. brightThreshold: number;
  71265. /**
  71266. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71267. */
  71268. blurWidth: number;
  71269. /**
  71270. * Sets if the blur for highlighted surfaces must be only horizontal
  71271. */
  71272. horizontalBlur: boolean;
  71273. /**
  71274. * Gets the overall exposure used by the pipeline
  71275. */
  71276. get exposure(): number;
  71277. /**
  71278. * Sets the overall exposure used by the pipeline
  71279. */
  71280. set exposure(value: number);
  71281. /**
  71282. * Texture used typically to simulate "dirty" on camera lens
  71283. */
  71284. lensTexture: Nullable<Texture>;
  71285. /**
  71286. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71287. */
  71288. volumetricLightCoefficient: number;
  71289. /**
  71290. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71291. */
  71292. volumetricLightPower: number;
  71293. /**
  71294. * Used the set the blur intensity to smooth the volumetric lights
  71295. */
  71296. volumetricLightBlurScale: number;
  71297. /**
  71298. * Light (spot or directional) used to generate the volumetric lights rays
  71299. * The source light must have a shadow generate so the pipeline can get its
  71300. * depth map
  71301. */
  71302. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71303. /**
  71304. * For eye adaptation, represents the minimum luminance the eye can see
  71305. */
  71306. hdrMinimumLuminance: number;
  71307. /**
  71308. * For eye adaptation, represents the decrease luminance speed
  71309. */
  71310. hdrDecreaseRate: number;
  71311. /**
  71312. * For eye adaptation, represents the increase luminance speed
  71313. */
  71314. hdrIncreaseRate: number;
  71315. /**
  71316. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71317. */
  71318. get hdrAutoExposure(): boolean;
  71319. /**
  71320. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71321. */
  71322. set hdrAutoExposure(value: boolean);
  71323. /**
  71324. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71325. */
  71326. lensColorTexture: Nullable<Texture>;
  71327. /**
  71328. * The overall strengh for the lens flare effect
  71329. */
  71330. lensFlareStrength: number;
  71331. /**
  71332. * Dispersion coefficient for lens flare ghosts
  71333. */
  71334. lensFlareGhostDispersal: number;
  71335. /**
  71336. * Main lens flare halo width
  71337. */
  71338. lensFlareHaloWidth: number;
  71339. /**
  71340. * Based on the lens distortion effect, defines how much the lens flare result
  71341. * is distorted
  71342. */
  71343. lensFlareDistortionStrength: number;
  71344. /**
  71345. * Configures the blur intensity used for for lens flare (halo)
  71346. */
  71347. lensFlareBlurWidth: number;
  71348. /**
  71349. * Lens star texture must be used to simulate rays on the flares and is available
  71350. * in the documentation
  71351. */
  71352. lensStarTexture: Nullable<Texture>;
  71353. /**
  71354. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71355. * flare effect by taking account of the dirt texture
  71356. */
  71357. lensFlareDirtTexture: Nullable<Texture>;
  71358. /**
  71359. * Represents the focal length for the depth of field effect
  71360. */
  71361. depthOfFieldDistance: number;
  71362. /**
  71363. * Represents the blur intensity for the blurred part of the depth of field effect
  71364. */
  71365. depthOfFieldBlurWidth: number;
  71366. /**
  71367. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71368. */
  71369. get motionStrength(): number;
  71370. /**
  71371. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71372. */
  71373. set motionStrength(strength: number);
  71374. /**
  71375. * Gets wether or not the motion blur post-process is object based or screen based.
  71376. */
  71377. get objectBasedMotionBlur(): boolean;
  71378. /**
  71379. * Sets wether or not the motion blur post-process should be object based or screen based
  71380. */
  71381. set objectBasedMotionBlur(value: boolean);
  71382. /**
  71383. * List of animations for the pipeline (IAnimatable implementation)
  71384. */
  71385. animations: Animation[];
  71386. /**
  71387. * Private members
  71388. */
  71389. private _scene;
  71390. private _currentDepthOfFieldSource;
  71391. private _basePostProcess;
  71392. private _fixedExposure;
  71393. private _currentExposure;
  71394. private _hdrAutoExposure;
  71395. private _hdrCurrentLuminance;
  71396. private _motionStrength;
  71397. private _isObjectBasedMotionBlur;
  71398. private _floatTextureType;
  71399. private _camerasToBeAttached;
  71400. private _ratio;
  71401. private _bloomEnabled;
  71402. private _depthOfFieldEnabled;
  71403. private _vlsEnabled;
  71404. private _lensFlareEnabled;
  71405. private _hdrEnabled;
  71406. private _motionBlurEnabled;
  71407. private _fxaaEnabled;
  71408. private _screenSpaceReflectionsEnabled;
  71409. private _motionBlurSamples;
  71410. private _volumetricLightStepsCount;
  71411. private _samples;
  71412. /**
  71413. * @ignore
  71414. * Specifies if the bloom pipeline is enabled
  71415. */
  71416. get BloomEnabled(): boolean;
  71417. set BloomEnabled(enabled: boolean);
  71418. /**
  71419. * @ignore
  71420. * Specifies if the depth of field pipeline is enabed
  71421. */
  71422. get DepthOfFieldEnabled(): boolean;
  71423. set DepthOfFieldEnabled(enabled: boolean);
  71424. /**
  71425. * @ignore
  71426. * Specifies if the lens flare pipeline is enabed
  71427. */
  71428. get LensFlareEnabled(): boolean;
  71429. set LensFlareEnabled(enabled: boolean);
  71430. /**
  71431. * @ignore
  71432. * Specifies if the HDR pipeline is enabled
  71433. */
  71434. get HDREnabled(): boolean;
  71435. set HDREnabled(enabled: boolean);
  71436. /**
  71437. * @ignore
  71438. * Specifies if the volumetric lights scattering effect is enabled
  71439. */
  71440. get VLSEnabled(): boolean;
  71441. set VLSEnabled(enabled: boolean);
  71442. /**
  71443. * @ignore
  71444. * Specifies if the motion blur effect is enabled
  71445. */
  71446. get MotionBlurEnabled(): boolean;
  71447. set MotionBlurEnabled(enabled: boolean);
  71448. /**
  71449. * Specifies if anti-aliasing is enabled
  71450. */
  71451. get fxaaEnabled(): boolean;
  71452. set fxaaEnabled(enabled: boolean);
  71453. /**
  71454. * Specifies if screen space reflections are enabled.
  71455. */
  71456. get screenSpaceReflectionsEnabled(): boolean;
  71457. set screenSpaceReflectionsEnabled(enabled: boolean);
  71458. /**
  71459. * Specifies the number of steps used to calculate the volumetric lights
  71460. * Typically in interval [50, 200]
  71461. */
  71462. get volumetricLightStepsCount(): number;
  71463. set volumetricLightStepsCount(count: number);
  71464. /**
  71465. * Specifies the number of samples used for the motion blur effect
  71466. * Typically in interval [16, 64]
  71467. */
  71468. get motionBlurSamples(): number;
  71469. set motionBlurSamples(samples: number);
  71470. /**
  71471. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71472. */
  71473. get samples(): number;
  71474. set samples(sampleCount: number);
  71475. /**
  71476. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71477. * @constructor
  71478. * @param name The rendering pipeline name
  71479. * @param scene The scene linked to this pipeline
  71480. * @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)
  71481. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71482. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71483. */
  71484. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71485. private _buildPipeline;
  71486. private _createDownSampleX4PostProcess;
  71487. private _createBrightPassPostProcess;
  71488. private _createBlurPostProcesses;
  71489. private _createTextureAdderPostProcess;
  71490. private _createVolumetricLightPostProcess;
  71491. private _createLuminancePostProcesses;
  71492. private _createHdrPostProcess;
  71493. private _createLensFlarePostProcess;
  71494. private _createDepthOfFieldPostProcess;
  71495. private _createMotionBlurPostProcess;
  71496. private _getDepthTexture;
  71497. private _disposePostProcesses;
  71498. /**
  71499. * Dispose of the pipeline and stop all post processes
  71500. */
  71501. dispose(): void;
  71502. /**
  71503. * Serialize the rendering pipeline (Used when exporting)
  71504. * @returns the serialized object
  71505. */
  71506. serialize(): any;
  71507. /**
  71508. * Parse the serialized pipeline
  71509. * @param source Source pipeline.
  71510. * @param scene The scene to load the pipeline to.
  71511. * @param rootUrl The URL of the serialized pipeline.
  71512. * @returns An instantiated pipeline from the serialized object.
  71513. */
  71514. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71515. /**
  71516. * Luminance steps
  71517. */
  71518. static LuminanceSteps: number;
  71519. }
  71520. }
  71521. declare module BABYLON {
  71522. /** @hidden */
  71523. export var stereoscopicInterlacePixelShader: {
  71524. name: string;
  71525. shader: string;
  71526. };
  71527. }
  71528. declare module BABYLON {
  71529. /**
  71530. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71531. */
  71532. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71533. private _stepSize;
  71534. private _passedProcess;
  71535. /**
  71536. * Gets a string identifying the name of the class
  71537. * @returns "StereoscopicInterlacePostProcessI" string
  71538. */
  71539. getClassName(): string;
  71540. /**
  71541. * Initializes a StereoscopicInterlacePostProcessI
  71542. * @param name The name of the effect.
  71543. * @param rigCameras The rig cameras to be appled to the post process
  71544. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71545. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71547. * @param engine The engine which the post process will be applied. (default: current engine)
  71548. * @param reusable If the post process can be reused on the same frame. (default: false)
  71549. */
  71550. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71551. }
  71552. /**
  71553. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71554. */
  71555. export class StereoscopicInterlacePostProcess extends PostProcess {
  71556. private _stepSize;
  71557. private _passedProcess;
  71558. /**
  71559. * Gets a string identifying the name of the class
  71560. * @returns "StereoscopicInterlacePostProcess" string
  71561. */
  71562. getClassName(): string;
  71563. /**
  71564. * Initializes a StereoscopicInterlacePostProcess
  71565. * @param name The name of the effect.
  71566. * @param rigCameras The rig cameras to be appled to the post process
  71567. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71569. * @param engine The engine which the post process will be applied. (default: current engine)
  71570. * @param reusable If the post process can be reused on the same frame. (default: false)
  71571. */
  71572. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71573. }
  71574. }
  71575. declare module BABYLON {
  71576. /** @hidden */
  71577. export var tonemapPixelShader: {
  71578. name: string;
  71579. shader: string;
  71580. };
  71581. }
  71582. declare module BABYLON {
  71583. /** Defines operator used for tonemapping */
  71584. export enum TonemappingOperator {
  71585. /** Hable */
  71586. Hable = 0,
  71587. /** Reinhard */
  71588. Reinhard = 1,
  71589. /** HejiDawson */
  71590. HejiDawson = 2,
  71591. /** Photographic */
  71592. Photographic = 3
  71593. }
  71594. /**
  71595. * Defines a post process to apply tone mapping
  71596. */
  71597. export class TonemapPostProcess extends PostProcess {
  71598. private _operator;
  71599. /** Defines the required exposure adjustement */
  71600. exposureAdjustment: number;
  71601. /**
  71602. * Gets a string identifying the name of the class
  71603. * @returns "TonemapPostProcess" string
  71604. */
  71605. getClassName(): string;
  71606. /**
  71607. * Creates a new TonemapPostProcess
  71608. * @param name defines the name of the postprocess
  71609. * @param _operator defines the operator to use
  71610. * @param exposureAdjustment defines the required exposure adjustement
  71611. * @param camera defines the camera to use (can be null)
  71612. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71613. * @param engine defines the hosting engine (can be ignore if camera is set)
  71614. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71615. */
  71616. constructor(name: string, _operator: TonemappingOperator,
  71617. /** Defines the required exposure adjustement */
  71618. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71619. }
  71620. }
  71621. declare module BABYLON {
  71622. /** @hidden */
  71623. export var volumetricLightScatteringPixelShader: {
  71624. name: string;
  71625. shader: string;
  71626. };
  71627. }
  71628. declare module BABYLON {
  71629. /** @hidden */
  71630. export var volumetricLightScatteringPassVertexShader: {
  71631. name: string;
  71632. shader: string;
  71633. };
  71634. }
  71635. declare module BABYLON {
  71636. /** @hidden */
  71637. export var volumetricLightScatteringPassPixelShader: {
  71638. name: string;
  71639. shader: string;
  71640. };
  71641. }
  71642. declare module BABYLON {
  71643. /**
  71644. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71645. */
  71646. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71647. private _volumetricLightScatteringPass;
  71648. private _volumetricLightScatteringRTT;
  71649. private _viewPort;
  71650. private _screenCoordinates;
  71651. private _cachedDefines;
  71652. /**
  71653. * If not undefined, the mesh position is computed from the attached node position
  71654. */
  71655. attachedNode: {
  71656. position: Vector3;
  71657. };
  71658. /**
  71659. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71660. */
  71661. customMeshPosition: Vector3;
  71662. /**
  71663. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71664. */
  71665. useCustomMeshPosition: boolean;
  71666. /**
  71667. * If the post-process should inverse the light scattering direction
  71668. */
  71669. invert: boolean;
  71670. /**
  71671. * The internal mesh used by the post-process
  71672. */
  71673. mesh: Mesh;
  71674. /**
  71675. * @hidden
  71676. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71677. */
  71678. get useDiffuseColor(): boolean;
  71679. set useDiffuseColor(useDiffuseColor: boolean);
  71680. /**
  71681. * Array containing the excluded meshes not rendered in the internal pass
  71682. */
  71683. excludedMeshes: AbstractMesh[];
  71684. /**
  71685. * Controls the overall intensity of the post-process
  71686. */
  71687. exposure: number;
  71688. /**
  71689. * Dissipates each sample's contribution in range [0, 1]
  71690. */
  71691. decay: number;
  71692. /**
  71693. * Controls the overall intensity of each sample
  71694. */
  71695. weight: number;
  71696. /**
  71697. * Controls the density of each sample
  71698. */
  71699. density: number;
  71700. /**
  71701. * @constructor
  71702. * @param name The post-process name
  71703. * @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)
  71704. * @param camera The camera that the post-process will be attached to
  71705. * @param mesh The mesh used to create the light scattering
  71706. * @param samples The post-process quality, default 100
  71707. * @param samplingModeThe post-process filtering mode
  71708. * @param engine The babylon engine
  71709. * @param reusable If the post-process is reusable
  71710. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71711. */
  71712. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71713. /**
  71714. * Returns the string "VolumetricLightScatteringPostProcess"
  71715. * @returns "VolumetricLightScatteringPostProcess"
  71716. */
  71717. getClassName(): string;
  71718. private _isReady;
  71719. /**
  71720. * Sets the new light position for light scattering effect
  71721. * @param position The new custom light position
  71722. */
  71723. setCustomMeshPosition(position: Vector3): void;
  71724. /**
  71725. * Returns the light position for light scattering effect
  71726. * @return Vector3 The custom light position
  71727. */
  71728. getCustomMeshPosition(): Vector3;
  71729. /**
  71730. * Disposes the internal assets and detaches the post-process from the camera
  71731. */
  71732. dispose(camera: Camera): void;
  71733. /**
  71734. * Returns the render target texture used by the post-process
  71735. * @return the render target texture used by the post-process
  71736. */
  71737. getPass(): RenderTargetTexture;
  71738. private _meshExcluded;
  71739. private _createPass;
  71740. private _updateMeshScreenCoordinates;
  71741. /**
  71742. * Creates a default mesh for the Volumeric Light Scattering post-process
  71743. * @param name The mesh name
  71744. * @param scene The scene where to create the mesh
  71745. * @return the default mesh
  71746. */
  71747. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71748. }
  71749. }
  71750. declare module BABYLON {
  71751. /** @hidden */
  71752. export var screenSpaceCurvaturePixelShader: {
  71753. name: string;
  71754. shader: string;
  71755. };
  71756. }
  71757. declare module BABYLON {
  71758. /**
  71759. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71760. */
  71761. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71762. /**
  71763. * Defines how much ridge the curvature effect displays.
  71764. */
  71765. ridge: number;
  71766. /**
  71767. * Defines how much valley the curvature effect displays.
  71768. */
  71769. valley: number;
  71770. private _geometryBufferRenderer;
  71771. /**
  71772. * Gets a string identifying the name of the class
  71773. * @returns "ScreenSpaceCurvaturePostProcess" string
  71774. */
  71775. getClassName(): string;
  71776. /**
  71777. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71778. * @param name The name of the effect.
  71779. * @param scene The scene containing the objects to blur according to their velocity.
  71780. * @param options The required width/height ratio to downsize to before computing the render pass.
  71781. * @param camera The camera to apply the render pass to.
  71782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71783. * @param engine The engine which the post process will be applied. (default: current engine)
  71784. * @param reusable If the post process can be reused on the same frame. (default: false)
  71785. * @param textureType Type of textures used when performing the post process. (default: 0)
  71786. * @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)
  71787. */
  71788. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71789. /**
  71790. * Support test.
  71791. */
  71792. static get IsSupported(): boolean;
  71793. /** @hidden */
  71794. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71795. }
  71796. }
  71797. declare module BABYLON {
  71798. interface Scene {
  71799. /** @hidden (Backing field) */
  71800. _boundingBoxRenderer: BoundingBoxRenderer;
  71801. /** @hidden (Backing field) */
  71802. _forceShowBoundingBoxes: boolean;
  71803. /**
  71804. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71805. */
  71806. forceShowBoundingBoxes: boolean;
  71807. /**
  71808. * Gets the bounding box renderer associated with the scene
  71809. * @returns a BoundingBoxRenderer
  71810. */
  71811. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71812. }
  71813. interface AbstractMesh {
  71814. /** @hidden (Backing field) */
  71815. _showBoundingBox: boolean;
  71816. /**
  71817. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71818. */
  71819. showBoundingBox: boolean;
  71820. }
  71821. /**
  71822. * Component responsible of rendering the bounding box of the meshes in a scene.
  71823. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71824. */
  71825. export class BoundingBoxRenderer implements ISceneComponent {
  71826. /**
  71827. * The component name helpfull to identify the component in the list of scene components.
  71828. */
  71829. readonly name: string;
  71830. /**
  71831. * The scene the component belongs to.
  71832. */
  71833. scene: Scene;
  71834. /**
  71835. * Color of the bounding box lines placed in front of an object
  71836. */
  71837. frontColor: Color3;
  71838. /**
  71839. * Color of the bounding box lines placed behind an object
  71840. */
  71841. backColor: Color3;
  71842. /**
  71843. * Defines if the renderer should show the back lines or not
  71844. */
  71845. showBackLines: boolean;
  71846. /**
  71847. * Observable raised before rendering a bounding box
  71848. */
  71849. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71850. /**
  71851. * Observable raised after rendering a bounding box
  71852. */
  71853. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71854. /**
  71855. * @hidden
  71856. */
  71857. renderList: SmartArray<BoundingBox>;
  71858. private _colorShader;
  71859. private _vertexBuffers;
  71860. private _indexBuffer;
  71861. private _fillIndexBuffer;
  71862. private _fillIndexData;
  71863. /**
  71864. * Instantiates a new bounding box renderer in a scene.
  71865. * @param scene the scene the renderer renders in
  71866. */
  71867. constructor(scene: Scene);
  71868. /**
  71869. * Registers the component in a given scene
  71870. */
  71871. register(): void;
  71872. private _evaluateSubMesh;
  71873. private _activeMesh;
  71874. private _prepareRessources;
  71875. private _createIndexBuffer;
  71876. /**
  71877. * Rebuilds the elements related to this component in case of
  71878. * context lost for instance.
  71879. */
  71880. rebuild(): void;
  71881. /**
  71882. * @hidden
  71883. */
  71884. reset(): void;
  71885. /**
  71886. * Render the bounding boxes of a specific rendering group
  71887. * @param renderingGroupId defines the rendering group to render
  71888. */
  71889. render(renderingGroupId: number): void;
  71890. /**
  71891. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71892. * @param mesh Define the mesh to render the occlusion bounding box for
  71893. */
  71894. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71895. /**
  71896. * Dispose and release the resources attached to this renderer.
  71897. */
  71898. dispose(): void;
  71899. }
  71900. }
  71901. declare module BABYLON {
  71902. interface Scene {
  71903. /** @hidden (Backing field) */
  71904. _depthRenderer: {
  71905. [id: string]: DepthRenderer;
  71906. };
  71907. /**
  71908. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71909. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71910. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71911. * @returns the created depth renderer
  71912. */
  71913. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71914. /**
  71915. * Disables a depth renderer for a given camera
  71916. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71917. */
  71918. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71919. }
  71920. /**
  71921. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71922. * in several rendering techniques.
  71923. */
  71924. export class DepthRendererSceneComponent implements ISceneComponent {
  71925. /**
  71926. * The component name helpfull to identify the component in the list of scene components.
  71927. */
  71928. readonly name: string;
  71929. /**
  71930. * The scene the component belongs to.
  71931. */
  71932. scene: Scene;
  71933. /**
  71934. * Creates a new instance of the component for the given scene
  71935. * @param scene Defines the scene to register the component in
  71936. */
  71937. constructor(scene: Scene);
  71938. /**
  71939. * Registers the component in a given scene
  71940. */
  71941. register(): void;
  71942. /**
  71943. * Rebuilds the elements related to this component in case of
  71944. * context lost for instance.
  71945. */
  71946. rebuild(): void;
  71947. /**
  71948. * Disposes the component and the associated ressources
  71949. */
  71950. dispose(): void;
  71951. private _gatherRenderTargets;
  71952. private _gatherActiveCameraRenderTargets;
  71953. }
  71954. }
  71955. declare module BABYLON {
  71956. interface AbstractScene {
  71957. /** @hidden (Backing field) */
  71958. _prePassRenderer: Nullable<PrePassRenderer>;
  71959. /**
  71960. * Gets or Sets the current prepass renderer associated to the scene.
  71961. */
  71962. prePassRenderer: Nullable<PrePassRenderer>;
  71963. /**
  71964. * Enables the prepass and associates it with the scene
  71965. * @returns the PrePassRenderer
  71966. */
  71967. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71968. /**
  71969. * Disables the prepass associated with the scene
  71970. */
  71971. disablePrePassRenderer(): void;
  71972. }
  71973. /**
  71974. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71975. * in several rendering techniques.
  71976. */
  71977. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71978. /**
  71979. * The component name helpful to identify the component in the list of scene components.
  71980. */
  71981. readonly name: string;
  71982. /**
  71983. * The scene the component belongs to.
  71984. */
  71985. scene: Scene;
  71986. /**
  71987. * Creates a new instance of the component for the given scene
  71988. * @param scene Defines the scene to register the component in
  71989. */
  71990. constructor(scene: Scene);
  71991. /**
  71992. * Registers the component in a given scene
  71993. */
  71994. register(): void;
  71995. private _beforeCameraDraw;
  71996. private _afterCameraDraw;
  71997. private _beforeClearStage;
  71998. /**
  71999. * Serializes the component data to the specified json object
  72000. * @param serializationObject The object to serialize to
  72001. */
  72002. serialize(serializationObject: any): void;
  72003. /**
  72004. * Adds all the elements from the container to the scene
  72005. * @param container the container holding the elements
  72006. */
  72007. addFromContainer(container: AbstractScene): void;
  72008. /**
  72009. * Removes all the elements in the container from the scene
  72010. * @param container contains the elements to remove
  72011. * @param dispose if the removed element should be disposed (default: false)
  72012. */
  72013. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72014. /**
  72015. * Rebuilds the elements related to this component in case of
  72016. * context lost for instance.
  72017. */
  72018. rebuild(): void;
  72019. /**
  72020. * Disposes the component and the associated ressources
  72021. */
  72022. dispose(): void;
  72023. }
  72024. }
  72025. declare module BABYLON {
  72026. /** @hidden */
  72027. export var outlinePixelShader: {
  72028. name: string;
  72029. shader: string;
  72030. };
  72031. }
  72032. declare module BABYLON {
  72033. /** @hidden */
  72034. export var outlineVertexShader: {
  72035. name: string;
  72036. shader: string;
  72037. };
  72038. }
  72039. declare module BABYLON {
  72040. interface Scene {
  72041. /** @hidden */
  72042. _outlineRenderer: OutlineRenderer;
  72043. /**
  72044. * Gets the outline renderer associated with the scene
  72045. * @returns a OutlineRenderer
  72046. */
  72047. getOutlineRenderer(): OutlineRenderer;
  72048. }
  72049. interface AbstractMesh {
  72050. /** @hidden (Backing field) */
  72051. _renderOutline: boolean;
  72052. /**
  72053. * Gets or sets a boolean indicating if the outline must be rendered as well
  72054. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72055. */
  72056. renderOutline: boolean;
  72057. /** @hidden (Backing field) */
  72058. _renderOverlay: boolean;
  72059. /**
  72060. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72061. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72062. */
  72063. renderOverlay: boolean;
  72064. }
  72065. /**
  72066. * This class is responsible to draw bothe outline/overlay of meshes.
  72067. * It should not be used directly but through the available method on mesh.
  72068. */
  72069. export class OutlineRenderer implements ISceneComponent {
  72070. /**
  72071. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72072. */
  72073. private static _StencilReference;
  72074. /**
  72075. * The name of the component. Each component must have a unique name.
  72076. */
  72077. name: string;
  72078. /**
  72079. * The scene the component belongs to.
  72080. */
  72081. scene: Scene;
  72082. /**
  72083. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72084. */
  72085. zOffset: number;
  72086. private _engine;
  72087. private _effect;
  72088. private _cachedDefines;
  72089. private _savedDepthWrite;
  72090. /**
  72091. * Instantiates a new outline renderer. (There could be only one per scene).
  72092. * @param scene Defines the scene it belongs to
  72093. */
  72094. constructor(scene: Scene);
  72095. /**
  72096. * Register the component to one instance of a scene.
  72097. */
  72098. register(): void;
  72099. /**
  72100. * Rebuilds the elements related to this component in case of
  72101. * context lost for instance.
  72102. */
  72103. rebuild(): void;
  72104. /**
  72105. * Disposes the component and the associated ressources.
  72106. */
  72107. dispose(): void;
  72108. /**
  72109. * Renders the outline in the canvas.
  72110. * @param subMesh Defines the sumesh to render
  72111. * @param batch Defines the batch of meshes in case of instances
  72112. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72113. */
  72114. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72115. /**
  72116. * Returns whether or not the outline renderer is ready for a given submesh.
  72117. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72118. * @param subMesh Defines the submesh to check readyness for
  72119. * @param useInstances Defines wheter wee are trying to render instances or not
  72120. * @returns true if ready otherwise false
  72121. */
  72122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72123. private _beforeRenderingMesh;
  72124. private _afterRenderingMesh;
  72125. }
  72126. }
  72127. declare module BABYLON {
  72128. /**
  72129. * Defines the basic options interface of a Sprite Frame Source Size.
  72130. */
  72131. export interface ISpriteJSONSpriteSourceSize {
  72132. /**
  72133. * number of the original width of the Frame
  72134. */
  72135. w: number;
  72136. /**
  72137. * number of the original height of the Frame
  72138. */
  72139. h: number;
  72140. }
  72141. /**
  72142. * Defines the basic options interface of a Sprite Frame Data.
  72143. */
  72144. export interface ISpriteJSONSpriteFrameData {
  72145. /**
  72146. * number of the x offset of the Frame
  72147. */
  72148. x: number;
  72149. /**
  72150. * number of the y offset of the Frame
  72151. */
  72152. y: number;
  72153. /**
  72154. * number of the width of the Frame
  72155. */
  72156. w: number;
  72157. /**
  72158. * number of the height of the Frame
  72159. */
  72160. h: number;
  72161. }
  72162. /**
  72163. * Defines the basic options interface of a JSON Sprite.
  72164. */
  72165. export interface ISpriteJSONSprite {
  72166. /**
  72167. * string name of the Frame
  72168. */
  72169. filename: string;
  72170. /**
  72171. * ISpriteJSONSpriteFrame basic object of the frame data
  72172. */
  72173. frame: ISpriteJSONSpriteFrameData;
  72174. /**
  72175. * boolean to flag is the frame was rotated.
  72176. */
  72177. rotated: boolean;
  72178. /**
  72179. * boolean to flag is the frame was trimmed.
  72180. */
  72181. trimmed: boolean;
  72182. /**
  72183. * ISpriteJSONSpriteFrame basic object of the source data
  72184. */
  72185. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72186. /**
  72187. * ISpriteJSONSpriteFrame basic object of the source data
  72188. */
  72189. sourceSize: ISpriteJSONSpriteSourceSize;
  72190. }
  72191. /**
  72192. * Defines the basic options interface of a JSON atlas.
  72193. */
  72194. export interface ISpriteJSONAtlas {
  72195. /**
  72196. * Array of objects that contain the frame data.
  72197. */
  72198. frames: Array<ISpriteJSONSprite>;
  72199. /**
  72200. * object basic object containing the sprite meta data.
  72201. */
  72202. meta?: object;
  72203. }
  72204. }
  72205. declare module BABYLON {
  72206. /** @hidden */
  72207. export var spriteMapPixelShader: {
  72208. name: string;
  72209. shader: string;
  72210. };
  72211. }
  72212. declare module BABYLON {
  72213. /** @hidden */
  72214. export var spriteMapVertexShader: {
  72215. name: string;
  72216. shader: string;
  72217. };
  72218. }
  72219. declare module BABYLON {
  72220. /**
  72221. * Defines the basic options interface of a SpriteMap
  72222. */
  72223. export interface ISpriteMapOptions {
  72224. /**
  72225. * Vector2 of the number of cells in the grid.
  72226. */
  72227. stageSize?: Vector2;
  72228. /**
  72229. * Vector2 of the size of the output plane in World Units.
  72230. */
  72231. outputSize?: Vector2;
  72232. /**
  72233. * Vector3 of the position of the output plane in World Units.
  72234. */
  72235. outputPosition?: Vector3;
  72236. /**
  72237. * Vector3 of the rotation of the output plane.
  72238. */
  72239. outputRotation?: Vector3;
  72240. /**
  72241. * number of layers that the system will reserve in resources.
  72242. */
  72243. layerCount?: number;
  72244. /**
  72245. * number of max animation frames a single cell will reserve in resources.
  72246. */
  72247. maxAnimationFrames?: number;
  72248. /**
  72249. * number cell index of the base tile when the system compiles.
  72250. */
  72251. baseTile?: number;
  72252. /**
  72253. * boolean flip the sprite after its been repositioned by the framing data.
  72254. */
  72255. flipU?: boolean;
  72256. /**
  72257. * Vector3 scalar of the global RGB values of the SpriteMap.
  72258. */
  72259. colorMultiply?: Vector3;
  72260. }
  72261. /**
  72262. * Defines the IDisposable interface in order to be cleanable from resources.
  72263. */
  72264. export interface ISpriteMap extends IDisposable {
  72265. /**
  72266. * String name of the SpriteMap.
  72267. */
  72268. name: string;
  72269. /**
  72270. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72271. */
  72272. atlasJSON: ISpriteJSONAtlas;
  72273. /**
  72274. * Texture of the SpriteMap.
  72275. */
  72276. spriteSheet: Texture;
  72277. /**
  72278. * The parameters to initialize the SpriteMap with.
  72279. */
  72280. options: ISpriteMapOptions;
  72281. }
  72282. /**
  72283. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72284. */
  72285. export class SpriteMap implements ISpriteMap {
  72286. /** The Name of the spriteMap */
  72287. name: string;
  72288. /** The JSON file with the frame and meta data */
  72289. atlasJSON: ISpriteJSONAtlas;
  72290. /** The systems Sprite Sheet Texture */
  72291. spriteSheet: Texture;
  72292. /** Arguments passed with the Constructor */
  72293. options: ISpriteMapOptions;
  72294. /** Public Sprite Storage array, parsed from atlasJSON */
  72295. sprites: Array<ISpriteJSONSprite>;
  72296. /** Returns the Number of Sprites in the System */
  72297. get spriteCount(): number;
  72298. /** Returns the Position of Output Plane*/
  72299. get position(): Vector3;
  72300. /** Returns the Position of Output Plane*/
  72301. set position(v: Vector3);
  72302. /** Returns the Rotation of Output Plane*/
  72303. get rotation(): Vector3;
  72304. /** Returns the Rotation of Output Plane*/
  72305. set rotation(v: Vector3);
  72306. /** Sets the AnimationMap*/
  72307. get animationMap(): RawTexture;
  72308. /** Sets the AnimationMap*/
  72309. set animationMap(v: RawTexture);
  72310. /** Scene that the SpriteMap was created in */
  72311. private _scene;
  72312. /** Texture Buffer of Float32 that holds tile frame data*/
  72313. private _frameMap;
  72314. /** Texture Buffers of Float32 that holds tileMap data*/
  72315. private _tileMaps;
  72316. /** Texture Buffer of Float32 that holds Animation Data*/
  72317. private _animationMap;
  72318. /** Custom ShaderMaterial Central to the System*/
  72319. private _material;
  72320. /** Custom ShaderMaterial Central to the System*/
  72321. private _output;
  72322. /** Systems Time Ticker*/
  72323. private _time;
  72324. /**
  72325. * Creates a new SpriteMap
  72326. * @param name defines the SpriteMaps Name
  72327. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72328. * @param spriteSheet is the Texture that the Sprites are on.
  72329. * @param options a basic deployment configuration
  72330. * @param scene The Scene that the map is deployed on
  72331. */
  72332. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72333. /**
  72334. * Returns tileID location
  72335. * @returns Vector2 the cell position ID
  72336. */
  72337. getTileID(): Vector2;
  72338. /**
  72339. * Gets the UV location of the mouse over the SpriteMap.
  72340. * @returns Vector2 the UV position of the mouse interaction
  72341. */
  72342. getMousePosition(): Vector2;
  72343. /**
  72344. * Creates the "frame" texture Buffer
  72345. * -------------------------------------
  72346. * Structure of frames
  72347. * "filename": "Falling-Water-2.png",
  72348. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72349. * "rotated": true,
  72350. * "trimmed": true,
  72351. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72352. * "sourceSize": {"w":32,"h":32}
  72353. * @returns RawTexture of the frameMap
  72354. */
  72355. private _createFrameBuffer;
  72356. /**
  72357. * Creates the tileMap texture Buffer
  72358. * @param buffer normally and array of numbers, or a false to generate from scratch
  72359. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72360. * @returns RawTexture of the tileMap
  72361. */
  72362. private _createTileBuffer;
  72363. /**
  72364. * Modifies the data of the tileMaps
  72365. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72366. * @param pos is the iVector2 Coordinates of the Tile
  72367. * @param tile The SpriteIndex of the new Tile
  72368. */
  72369. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72370. /**
  72371. * Creates the animationMap texture Buffer
  72372. * @param buffer normally and array of numbers, or a false to generate from scratch
  72373. * @returns RawTexture of the animationMap
  72374. */
  72375. private _createTileAnimationBuffer;
  72376. /**
  72377. * Modifies the data of the animationMap
  72378. * @param cellID is the Index of the Sprite
  72379. * @param _frame is the target Animation frame
  72380. * @param toCell is the Target Index of the next frame of the animation
  72381. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72382. * @param speed is a global scalar of the time variable on the map.
  72383. */
  72384. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72385. /**
  72386. * Exports the .tilemaps file
  72387. */
  72388. saveTileMaps(): void;
  72389. /**
  72390. * Imports the .tilemaps file
  72391. * @param url of the .tilemaps file
  72392. */
  72393. loadTileMaps(url: string): void;
  72394. /**
  72395. * Release associated resources
  72396. */
  72397. dispose(): void;
  72398. }
  72399. }
  72400. declare module BABYLON {
  72401. /**
  72402. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72403. * @see https://doc.babylonjs.com/babylon101/sprites
  72404. */
  72405. export class SpritePackedManager extends SpriteManager {
  72406. /** defines the packed manager's name */
  72407. name: string;
  72408. /**
  72409. * Creates a new sprite manager from a packed sprite sheet
  72410. * @param name defines the manager's name
  72411. * @param imgUrl defines the sprite sheet url
  72412. * @param capacity defines the maximum allowed number of sprites
  72413. * @param scene defines the hosting scene
  72414. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72415. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72416. * @param samplingMode defines the smapling mode to use with spritesheet
  72417. * @param fromPacked set to true; do not alter
  72418. */
  72419. constructor(
  72420. /** defines the packed manager's name */
  72421. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72422. }
  72423. }
  72424. declare module BABYLON {
  72425. /**
  72426. * Defines the list of states available for a task inside a AssetsManager
  72427. */
  72428. export enum AssetTaskState {
  72429. /**
  72430. * Initialization
  72431. */
  72432. INIT = 0,
  72433. /**
  72434. * Running
  72435. */
  72436. RUNNING = 1,
  72437. /**
  72438. * Done
  72439. */
  72440. DONE = 2,
  72441. /**
  72442. * Error
  72443. */
  72444. ERROR = 3
  72445. }
  72446. /**
  72447. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72448. */
  72449. export abstract class AbstractAssetTask {
  72450. /**
  72451. * Task name
  72452. */ name: string;
  72453. /**
  72454. * Callback called when the task is successful
  72455. */
  72456. onSuccess: (task: any) => void;
  72457. /**
  72458. * Callback called when the task is not successful
  72459. */
  72460. onError: (task: any, message?: string, exception?: any) => void;
  72461. /**
  72462. * Creates a new AssetsManager
  72463. * @param name defines the name of the task
  72464. */
  72465. constructor(
  72466. /**
  72467. * Task name
  72468. */ name: string);
  72469. private _isCompleted;
  72470. private _taskState;
  72471. private _errorObject;
  72472. /**
  72473. * Get if the task is completed
  72474. */
  72475. get isCompleted(): boolean;
  72476. /**
  72477. * Gets the current state of the task
  72478. */
  72479. get taskState(): AssetTaskState;
  72480. /**
  72481. * Gets the current error object (if task is in error)
  72482. */
  72483. get errorObject(): {
  72484. message?: string;
  72485. exception?: any;
  72486. };
  72487. /**
  72488. * Internal only
  72489. * @hidden
  72490. */
  72491. _setErrorObject(message?: string, exception?: any): void;
  72492. /**
  72493. * Execute the current task
  72494. * @param scene defines the scene where you want your assets to be loaded
  72495. * @param onSuccess is a callback called when the task is successfully executed
  72496. * @param onError is a callback called if an error occurs
  72497. */
  72498. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72499. /**
  72500. * Execute the current task
  72501. * @param scene defines the scene where you want your assets to be loaded
  72502. * @param onSuccess is a callback called when the task is successfully executed
  72503. * @param onError is a callback called if an error occurs
  72504. */
  72505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72506. /**
  72507. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72508. * This can be used with failed tasks that have the reason for failure fixed.
  72509. */
  72510. reset(): void;
  72511. private onErrorCallback;
  72512. private onDoneCallback;
  72513. }
  72514. /**
  72515. * Define the interface used by progress events raised during assets loading
  72516. */
  72517. export interface IAssetsProgressEvent {
  72518. /**
  72519. * Defines the number of remaining tasks to process
  72520. */
  72521. remainingCount: number;
  72522. /**
  72523. * Defines the total number of tasks
  72524. */
  72525. totalCount: number;
  72526. /**
  72527. * Defines the task that was just processed
  72528. */
  72529. task: AbstractAssetTask;
  72530. }
  72531. /**
  72532. * Class used to share progress information about assets loading
  72533. */
  72534. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72535. /**
  72536. * Defines the number of remaining tasks to process
  72537. */
  72538. remainingCount: number;
  72539. /**
  72540. * Defines the total number of tasks
  72541. */
  72542. totalCount: number;
  72543. /**
  72544. * Defines the task that was just processed
  72545. */
  72546. task: AbstractAssetTask;
  72547. /**
  72548. * Creates a AssetsProgressEvent
  72549. * @param remainingCount defines the number of remaining tasks to process
  72550. * @param totalCount defines the total number of tasks
  72551. * @param task defines the task that was just processed
  72552. */
  72553. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72554. }
  72555. /**
  72556. * Define a task used by AssetsManager to load assets into a container
  72557. */
  72558. export class ContainerAssetTask extends AbstractAssetTask {
  72559. /**
  72560. * Defines the name of the task
  72561. */
  72562. name: string;
  72563. /**
  72564. * Defines the list of mesh's names you want to load
  72565. */
  72566. meshesNames: any;
  72567. /**
  72568. * Defines the root url to use as a base to load your meshes and associated resources
  72569. */
  72570. rootUrl: string;
  72571. /**
  72572. * Defines the filename or File of the scene to load from
  72573. */
  72574. sceneFilename: string | File;
  72575. /**
  72576. * Get the loaded asset container
  72577. */
  72578. loadedContainer: AssetContainer;
  72579. /**
  72580. * Gets the list of loaded meshes
  72581. */
  72582. loadedMeshes: Array<AbstractMesh>;
  72583. /**
  72584. * Gets the list of loaded particle systems
  72585. */
  72586. loadedParticleSystems: Array<IParticleSystem>;
  72587. /**
  72588. * Gets the list of loaded skeletons
  72589. */
  72590. loadedSkeletons: Array<Skeleton>;
  72591. /**
  72592. * Gets the list of loaded animation groups
  72593. */
  72594. loadedAnimationGroups: Array<AnimationGroup>;
  72595. /**
  72596. * Callback called when the task is successful
  72597. */
  72598. onSuccess: (task: ContainerAssetTask) => void;
  72599. /**
  72600. * Callback called when the task is successful
  72601. */
  72602. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72603. /**
  72604. * Creates a new ContainerAssetTask
  72605. * @param name defines the name of the task
  72606. * @param meshesNames defines the list of mesh's names you want to load
  72607. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72608. * @param sceneFilename defines the filename or File of the scene to load from
  72609. */
  72610. constructor(
  72611. /**
  72612. * Defines the name of the task
  72613. */
  72614. name: string,
  72615. /**
  72616. * Defines the list of mesh's names you want to load
  72617. */
  72618. meshesNames: any,
  72619. /**
  72620. * Defines the root url to use as a base to load your meshes and associated resources
  72621. */
  72622. rootUrl: string,
  72623. /**
  72624. * Defines the filename or File of the scene to load from
  72625. */
  72626. sceneFilename: string | File);
  72627. /**
  72628. * Execute the current task
  72629. * @param scene defines the scene where you want your assets to be loaded
  72630. * @param onSuccess is a callback called when the task is successfully executed
  72631. * @param onError is a callback called if an error occurs
  72632. */
  72633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72634. }
  72635. /**
  72636. * Define a task used by AssetsManager to load meshes
  72637. */
  72638. export class MeshAssetTask extends AbstractAssetTask {
  72639. /**
  72640. * Defines the name of the task
  72641. */
  72642. name: string;
  72643. /**
  72644. * Defines the list of mesh's names you want to load
  72645. */
  72646. meshesNames: any;
  72647. /**
  72648. * Defines the root url to use as a base to load your meshes and associated resources
  72649. */
  72650. rootUrl: string;
  72651. /**
  72652. * Defines the filename or File of the scene to load from
  72653. */
  72654. sceneFilename: string | File;
  72655. /**
  72656. * Gets the list of loaded meshes
  72657. */
  72658. loadedMeshes: Array<AbstractMesh>;
  72659. /**
  72660. * Gets the list of loaded particle systems
  72661. */
  72662. loadedParticleSystems: Array<IParticleSystem>;
  72663. /**
  72664. * Gets the list of loaded skeletons
  72665. */
  72666. loadedSkeletons: Array<Skeleton>;
  72667. /**
  72668. * Gets the list of loaded animation groups
  72669. */
  72670. loadedAnimationGroups: Array<AnimationGroup>;
  72671. /**
  72672. * Callback called when the task is successful
  72673. */
  72674. onSuccess: (task: MeshAssetTask) => void;
  72675. /**
  72676. * Callback called when the task is successful
  72677. */
  72678. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72679. /**
  72680. * Creates a new MeshAssetTask
  72681. * @param name defines the name of the task
  72682. * @param meshesNames defines the list of mesh's names you want to load
  72683. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72684. * @param sceneFilename defines the filename or File of the scene to load from
  72685. */
  72686. constructor(
  72687. /**
  72688. * Defines the name of the task
  72689. */
  72690. name: string,
  72691. /**
  72692. * Defines the list of mesh's names you want to load
  72693. */
  72694. meshesNames: any,
  72695. /**
  72696. * Defines the root url to use as a base to load your meshes and associated resources
  72697. */
  72698. rootUrl: string,
  72699. /**
  72700. * Defines the filename or File of the scene to load from
  72701. */
  72702. sceneFilename: string | File);
  72703. /**
  72704. * Execute the current task
  72705. * @param scene defines the scene where you want your assets to be loaded
  72706. * @param onSuccess is a callback called when the task is successfully executed
  72707. * @param onError is a callback called if an error occurs
  72708. */
  72709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72710. }
  72711. /**
  72712. * Define a task used by AssetsManager to load text content
  72713. */
  72714. export class TextFileAssetTask extends AbstractAssetTask {
  72715. /**
  72716. * Defines the name of the task
  72717. */
  72718. name: string;
  72719. /**
  72720. * Defines the location of the file to load
  72721. */
  72722. url: string;
  72723. /**
  72724. * Gets the loaded text string
  72725. */
  72726. text: string;
  72727. /**
  72728. * Callback called when the task is successful
  72729. */
  72730. onSuccess: (task: TextFileAssetTask) => void;
  72731. /**
  72732. * Callback called when the task is successful
  72733. */
  72734. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72735. /**
  72736. * Creates a new TextFileAssetTask object
  72737. * @param name defines the name of the task
  72738. * @param url defines the location of the file to load
  72739. */
  72740. constructor(
  72741. /**
  72742. * Defines the name of the task
  72743. */
  72744. name: string,
  72745. /**
  72746. * Defines the location of the file to load
  72747. */
  72748. url: string);
  72749. /**
  72750. * Execute the current task
  72751. * @param scene defines the scene where you want your assets to be loaded
  72752. * @param onSuccess is a callback called when the task is successfully executed
  72753. * @param onError is a callback called if an error occurs
  72754. */
  72755. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72756. }
  72757. /**
  72758. * Define a task used by AssetsManager to load binary data
  72759. */
  72760. export class BinaryFileAssetTask extends AbstractAssetTask {
  72761. /**
  72762. * Defines the name of the task
  72763. */
  72764. name: string;
  72765. /**
  72766. * Defines the location of the file to load
  72767. */
  72768. url: string;
  72769. /**
  72770. * Gets the lodaded data (as an array buffer)
  72771. */
  72772. data: ArrayBuffer;
  72773. /**
  72774. * Callback called when the task is successful
  72775. */
  72776. onSuccess: (task: BinaryFileAssetTask) => void;
  72777. /**
  72778. * Callback called when the task is successful
  72779. */
  72780. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72781. /**
  72782. * Creates a new BinaryFileAssetTask object
  72783. * @param name defines the name of the new task
  72784. * @param url defines the location of the file to load
  72785. */
  72786. constructor(
  72787. /**
  72788. * Defines the name of the task
  72789. */
  72790. name: string,
  72791. /**
  72792. * Defines the location of the file to load
  72793. */
  72794. url: string);
  72795. /**
  72796. * Execute the current task
  72797. * @param scene defines the scene where you want your assets to be loaded
  72798. * @param onSuccess is a callback called when the task is successfully executed
  72799. * @param onError is a callback called if an error occurs
  72800. */
  72801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72802. }
  72803. /**
  72804. * Define a task used by AssetsManager to load images
  72805. */
  72806. export class ImageAssetTask extends AbstractAssetTask {
  72807. /**
  72808. * Defines the name of the task
  72809. */
  72810. name: string;
  72811. /**
  72812. * Defines the location of the image to load
  72813. */
  72814. url: string;
  72815. /**
  72816. * Gets the loaded images
  72817. */
  72818. image: HTMLImageElement;
  72819. /**
  72820. * Callback called when the task is successful
  72821. */
  72822. onSuccess: (task: ImageAssetTask) => void;
  72823. /**
  72824. * Callback called when the task is successful
  72825. */
  72826. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72827. /**
  72828. * Creates a new ImageAssetTask
  72829. * @param name defines the name of the task
  72830. * @param url defines the location of the image to load
  72831. */
  72832. constructor(
  72833. /**
  72834. * Defines the name of the task
  72835. */
  72836. name: string,
  72837. /**
  72838. * Defines the location of the image to load
  72839. */
  72840. url: string);
  72841. /**
  72842. * Execute the current task
  72843. * @param scene defines the scene where you want your assets to be loaded
  72844. * @param onSuccess is a callback called when the task is successfully executed
  72845. * @param onError is a callback called if an error occurs
  72846. */
  72847. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72848. }
  72849. /**
  72850. * Defines the interface used by texture loading tasks
  72851. */
  72852. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72853. /**
  72854. * Gets the loaded texture
  72855. */
  72856. texture: TEX;
  72857. }
  72858. /**
  72859. * Define a task used by AssetsManager to load 2D textures
  72860. */
  72861. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72862. /**
  72863. * Defines the name of the task
  72864. */
  72865. name: string;
  72866. /**
  72867. * Defines the location of the file to load
  72868. */
  72869. url: string;
  72870. /**
  72871. * Defines if mipmap should not be generated (default is false)
  72872. */
  72873. noMipmap?: boolean | undefined;
  72874. /**
  72875. * Defines if texture must be inverted on Y axis (default is true)
  72876. */
  72877. invertY: boolean;
  72878. /**
  72879. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72880. */
  72881. samplingMode: number;
  72882. /**
  72883. * Gets the loaded texture
  72884. */
  72885. texture: Texture;
  72886. /**
  72887. * Callback called when the task is successful
  72888. */
  72889. onSuccess: (task: TextureAssetTask) => void;
  72890. /**
  72891. * Callback called when the task is successful
  72892. */
  72893. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72894. /**
  72895. * Creates a new TextureAssetTask object
  72896. * @param name defines the name of the task
  72897. * @param url defines the location of the file to load
  72898. * @param noMipmap defines if mipmap should not be generated (default is false)
  72899. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72900. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72901. */
  72902. constructor(
  72903. /**
  72904. * Defines the name of the task
  72905. */
  72906. name: string,
  72907. /**
  72908. * Defines the location of the file to load
  72909. */
  72910. url: string,
  72911. /**
  72912. * Defines if mipmap should not be generated (default is false)
  72913. */
  72914. noMipmap?: boolean | undefined,
  72915. /**
  72916. * Defines if texture must be inverted on Y axis (default is true)
  72917. */
  72918. invertY?: boolean,
  72919. /**
  72920. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72921. */
  72922. samplingMode?: number);
  72923. /**
  72924. * Execute the current task
  72925. * @param scene defines the scene where you want your assets to be loaded
  72926. * @param onSuccess is a callback called when the task is successfully executed
  72927. * @param onError is a callback called if an error occurs
  72928. */
  72929. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72930. }
  72931. /**
  72932. * Define a task used by AssetsManager to load cube textures
  72933. */
  72934. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72935. /**
  72936. * Defines the name of the task
  72937. */
  72938. name: string;
  72939. /**
  72940. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72941. */
  72942. url: string;
  72943. /**
  72944. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72945. */
  72946. extensions?: string[] | undefined;
  72947. /**
  72948. * Defines if mipmaps should not be generated (default is false)
  72949. */
  72950. noMipmap?: boolean | undefined;
  72951. /**
  72952. * Defines the explicit list of files (undefined by default)
  72953. */
  72954. files?: string[] | undefined;
  72955. /**
  72956. * Gets the loaded texture
  72957. */
  72958. texture: CubeTexture;
  72959. /**
  72960. * Callback called when the task is successful
  72961. */
  72962. onSuccess: (task: CubeTextureAssetTask) => void;
  72963. /**
  72964. * Callback called when the task is successful
  72965. */
  72966. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72967. /**
  72968. * Creates a new CubeTextureAssetTask
  72969. * @param name defines the name of the task
  72970. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72971. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72972. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72973. * @param files defines the explicit list of files (undefined by default)
  72974. */
  72975. constructor(
  72976. /**
  72977. * Defines the name of the task
  72978. */
  72979. name: string,
  72980. /**
  72981. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72982. */
  72983. url: string,
  72984. /**
  72985. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72986. */
  72987. extensions?: string[] | undefined,
  72988. /**
  72989. * Defines if mipmaps should not be generated (default is false)
  72990. */
  72991. noMipmap?: boolean | undefined,
  72992. /**
  72993. * Defines the explicit list of files (undefined by default)
  72994. */
  72995. files?: string[] | undefined);
  72996. /**
  72997. * Execute the current task
  72998. * @param scene defines the scene where you want your assets to be loaded
  72999. * @param onSuccess is a callback called when the task is successfully executed
  73000. * @param onError is a callback called if an error occurs
  73001. */
  73002. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73003. }
  73004. /**
  73005. * Define a task used by AssetsManager to load HDR cube textures
  73006. */
  73007. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73008. /**
  73009. * Defines the name of the task
  73010. */
  73011. name: string;
  73012. /**
  73013. * Defines the location of the file to load
  73014. */
  73015. url: string;
  73016. /**
  73017. * Defines the desired size (the more it increases the longer the generation will be)
  73018. */
  73019. size: number;
  73020. /**
  73021. * Defines if mipmaps should not be generated (default is false)
  73022. */
  73023. noMipmap: boolean;
  73024. /**
  73025. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73026. */
  73027. generateHarmonics: boolean;
  73028. /**
  73029. * 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)
  73030. */
  73031. gammaSpace: boolean;
  73032. /**
  73033. * Internal Use Only
  73034. */
  73035. reserved: boolean;
  73036. /**
  73037. * Gets the loaded texture
  73038. */
  73039. texture: HDRCubeTexture;
  73040. /**
  73041. * Callback called when the task is successful
  73042. */
  73043. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73044. /**
  73045. * Callback called when the task is successful
  73046. */
  73047. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73048. /**
  73049. * Creates a new HDRCubeTextureAssetTask object
  73050. * @param name defines the name of the task
  73051. * @param url defines the location of the file to load
  73052. * @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.
  73053. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73054. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73055. * @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)
  73056. * @param reserved Internal use only
  73057. */
  73058. constructor(
  73059. /**
  73060. * Defines the name of the task
  73061. */
  73062. name: string,
  73063. /**
  73064. * Defines the location of the file to load
  73065. */
  73066. url: string,
  73067. /**
  73068. * Defines the desired size (the more it increases the longer the generation will be)
  73069. */
  73070. size: number,
  73071. /**
  73072. * Defines if mipmaps should not be generated (default is false)
  73073. */
  73074. noMipmap?: boolean,
  73075. /**
  73076. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73077. */
  73078. generateHarmonics?: boolean,
  73079. /**
  73080. * 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)
  73081. */
  73082. gammaSpace?: boolean,
  73083. /**
  73084. * Internal Use Only
  73085. */
  73086. reserved?: boolean);
  73087. /**
  73088. * Execute the current task
  73089. * @param scene defines the scene where you want your assets to be loaded
  73090. * @param onSuccess is a callback called when the task is successfully executed
  73091. * @param onError is a callback called if an error occurs
  73092. */
  73093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73094. }
  73095. /**
  73096. * Define a task used by AssetsManager to load Equirectangular cube textures
  73097. */
  73098. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73099. /**
  73100. * Defines the name of the task
  73101. */
  73102. name: string;
  73103. /**
  73104. * Defines the location of the file to load
  73105. */
  73106. url: string;
  73107. /**
  73108. * Defines the desired size (the more it increases the longer the generation will be)
  73109. */
  73110. size: number;
  73111. /**
  73112. * Defines if mipmaps should not be generated (default is false)
  73113. */
  73114. noMipmap: boolean;
  73115. /**
  73116. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73117. * but the standard material would require them in Gamma space) (default is true)
  73118. */
  73119. gammaSpace: boolean;
  73120. /**
  73121. * Gets the loaded texture
  73122. */
  73123. texture: EquiRectangularCubeTexture;
  73124. /**
  73125. * Callback called when the task is successful
  73126. */
  73127. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73128. /**
  73129. * Callback called when the task is successful
  73130. */
  73131. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73132. /**
  73133. * Creates a new EquiRectangularCubeTextureAssetTask object
  73134. * @param name defines the name of the task
  73135. * @param url defines the location of the file to load
  73136. * @param size defines the desired size (the more it increases the longer the generation will be)
  73137. * If the size is omitted this implies you are using a preprocessed cubemap.
  73138. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73139. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73140. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73141. * (default is true)
  73142. */
  73143. constructor(
  73144. /**
  73145. * Defines the name of the task
  73146. */
  73147. name: string,
  73148. /**
  73149. * Defines the location of the file to load
  73150. */
  73151. url: string,
  73152. /**
  73153. * Defines the desired size (the more it increases the longer the generation will be)
  73154. */
  73155. size: number,
  73156. /**
  73157. * Defines if mipmaps should not be generated (default is false)
  73158. */
  73159. noMipmap?: boolean,
  73160. /**
  73161. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73162. * but the standard material would require them in Gamma space) (default is true)
  73163. */
  73164. gammaSpace?: boolean);
  73165. /**
  73166. * Execute the current task
  73167. * @param scene defines the scene where you want your assets to be loaded
  73168. * @param onSuccess is a callback called when the task is successfully executed
  73169. * @param onError is a callback called if an error occurs
  73170. */
  73171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73172. }
  73173. /**
  73174. * This class can be used to easily import assets into a scene
  73175. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73176. */
  73177. export class AssetsManager {
  73178. private _scene;
  73179. private _isLoading;
  73180. protected _tasks: AbstractAssetTask[];
  73181. protected _waitingTasksCount: number;
  73182. protected _totalTasksCount: number;
  73183. /**
  73184. * Callback called when all tasks are processed
  73185. */
  73186. onFinish: (tasks: AbstractAssetTask[]) => void;
  73187. /**
  73188. * Callback called when a task is successful
  73189. */
  73190. onTaskSuccess: (task: AbstractAssetTask) => void;
  73191. /**
  73192. * Callback called when a task had an error
  73193. */
  73194. onTaskError: (task: AbstractAssetTask) => void;
  73195. /**
  73196. * Callback called when a task is done (whatever the result is)
  73197. */
  73198. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73199. /**
  73200. * Observable called when all tasks are processed
  73201. */
  73202. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73203. /**
  73204. * Observable called when a task had an error
  73205. */
  73206. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73207. /**
  73208. * Observable called when all tasks were executed
  73209. */
  73210. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73211. /**
  73212. * Observable called when a task is done (whatever the result is)
  73213. */
  73214. onProgressObservable: Observable<IAssetsProgressEvent>;
  73215. /**
  73216. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73217. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73218. */
  73219. useDefaultLoadingScreen: boolean;
  73220. /**
  73221. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73222. * when all assets have been downloaded.
  73223. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73224. */
  73225. autoHideLoadingUI: boolean;
  73226. /**
  73227. * Creates a new AssetsManager
  73228. * @param scene defines the scene to work on
  73229. */
  73230. constructor(scene: Scene);
  73231. /**
  73232. * Add a ContainerAssetTask to the list of active tasks
  73233. * @param taskName defines the name of the new task
  73234. * @param meshesNames defines the name of meshes to load
  73235. * @param rootUrl defines the root url to use to locate files
  73236. * @param sceneFilename defines the filename of the scene file
  73237. * @returns a new ContainerAssetTask object
  73238. */
  73239. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73240. /**
  73241. * Add a MeshAssetTask to the list of active tasks
  73242. * @param taskName defines the name of the new task
  73243. * @param meshesNames defines the name of meshes to load
  73244. * @param rootUrl defines the root url to use to locate files
  73245. * @param sceneFilename defines the filename of the scene file
  73246. * @returns a new MeshAssetTask object
  73247. */
  73248. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73249. /**
  73250. * Add a TextFileAssetTask to the list of active tasks
  73251. * @param taskName defines the name of the new task
  73252. * @param url defines the url of the file to load
  73253. * @returns a new TextFileAssetTask object
  73254. */
  73255. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73256. /**
  73257. * Add a BinaryFileAssetTask to the list of active tasks
  73258. * @param taskName defines the name of the new task
  73259. * @param url defines the url of the file to load
  73260. * @returns a new BinaryFileAssetTask object
  73261. */
  73262. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73263. /**
  73264. * Add a ImageAssetTask to the list of active tasks
  73265. * @param taskName defines the name of the new task
  73266. * @param url defines the url of the file to load
  73267. * @returns a new ImageAssetTask object
  73268. */
  73269. addImageTask(taskName: string, url: string): ImageAssetTask;
  73270. /**
  73271. * Add a TextureAssetTask to the list of active tasks
  73272. * @param taskName defines the name of the new task
  73273. * @param url defines the url of the file to load
  73274. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73275. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73276. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73277. * @returns a new TextureAssetTask object
  73278. */
  73279. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73280. /**
  73281. * Add a CubeTextureAssetTask to the list of active tasks
  73282. * @param taskName defines the name of the new task
  73283. * @param url defines the url of the file to load
  73284. * @param extensions defines the extension to use to load the cube map (can be null)
  73285. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73286. * @param files defines the list of files to load (can be null)
  73287. * @returns a new CubeTextureAssetTask object
  73288. */
  73289. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73290. /**
  73291. *
  73292. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73293. * @param taskName defines the name of the new task
  73294. * @param url defines the url of the file to load
  73295. * @param size defines the size you want for the cubemap (can be null)
  73296. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73297. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73298. * @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)
  73299. * @param reserved Internal use only
  73300. * @returns a new HDRCubeTextureAssetTask object
  73301. */
  73302. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73303. /**
  73304. *
  73305. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73306. * @param taskName defines the name of the new task
  73307. * @param url defines the url of the file to load
  73308. * @param size defines the size you want for the cubemap (can be null)
  73309. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73310. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73311. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73312. * @returns a new EquiRectangularCubeTextureAssetTask object
  73313. */
  73314. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73315. /**
  73316. * Remove a task from the assets manager.
  73317. * @param task the task to remove
  73318. */
  73319. removeTask(task: AbstractAssetTask): void;
  73320. private _decreaseWaitingTasksCount;
  73321. private _runTask;
  73322. /**
  73323. * Reset the AssetsManager and remove all tasks
  73324. * @return the current instance of the AssetsManager
  73325. */
  73326. reset(): AssetsManager;
  73327. /**
  73328. * Start the loading process
  73329. * @return the current instance of the AssetsManager
  73330. */
  73331. load(): AssetsManager;
  73332. /**
  73333. * Start the loading process as an async operation
  73334. * @return a promise returning the list of failed tasks
  73335. */
  73336. loadAsync(): Promise<void>;
  73337. }
  73338. }
  73339. declare module BABYLON {
  73340. /**
  73341. * Wrapper class for promise with external resolve and reject.
  73342. */
  73343. export class Deferred<T> {
  73344. /**
  73345. * The promise associated with this deferred object.
  73346. */
  73347. readonly promise: Promise<T>;
  73348. private _resolve;
  73349. private _reject;
  73350. /**
  73351. * The resolve method of the promise associated with this deferred object.
  73352. */
  73353. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73354. /**
  73355. * The reject method of the promise associated with this deferred object.
  73356. */
  73357. get reject(): (reason?: any) => void;
  73358. /**
  73359. * Constructor for this deferred object.
  73360. */
  73361. constructor();
  73362. }
  73363. }
  73364. declare module BABYLON {
  73365. /**
  73366. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73367. */
  73368. export class MeshExploder {
  73369. private _centerMesh;
  73370. private _meshes;
  73371. private _meshesOrigins;
  73372. private _toCenterVectors;
  73373. private _scaledDirection;
  73374. private _newPosition;
  73375. private _centerPosition;
  73376. /**
  73377. * Explodes meshes from a center mesh.
  73378. * @param meshes The meshes to explode.
  73379. * @param centerMesh The mesh to be center of explosion.
  73380. */
  73381. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73382. private _setCenterMesh;
  73383. /**
  73384. * Get class name
  73385. * @returns "MeshExploder"
  73386. */
  73387. getClassName(): string;
  73388. /**
  73389. * "Exploded meshes"
  73390. * @returns Array of meshes with the centerMesh at index 0.
  73391. */
  73392. getMeshes(): Array<Mesh>;
  73393. /**
  73394. * Explodes meshes giving a specific direction
  73395. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73396. */
  73397. explode(direction?: number): void;
  73398. }
  73399. }
  73400. declare module BABYLON {
  73401. /**
  73402. * Class used to help managing file picking and drag'n'drop
  73403. */
  73404. export class FilesInput {
  73405. /**
  73406. * List of files ready to be loaded
  73407. */
  73408. static get FilesToLoad(): {
  73409. [key: string]: File;
  73410. };
  73411. /**
  73412. * Callback called when a file is processed
  73413. */
  73414. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73415. private _engine;
  73416. private _currentScene;
  73417. private _sceneLoadedCallback;
  73418. private _progressCallback;
  73419. private _additionalRenderLoopLogicCallback;
  73420. private _textureLoadingCallback;
  73421. private _startingProcessingFilesCallback;
  73422. private _onReloadCallback;
  73423. private _errorCallback;
  73424. private _elementToMonitor;
  73425. private _sceneFileToLoad;
  73426. private _filesToLoad;
  73427. /**
  73428. * Creates a new FilesInput
  73429. * @param engine defines the rendering engine
  73430. * @param scene defines the hosting scene
  73431. * @param sceneLoadedCallback callback called when scene is loaded
  73432. * @param progressCallback callback called to track progress
  73433. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73434. * @param textureLoadingCallback callback called when a texture is loading
  73435. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73436. * @param onReloadCallback callback called when a reload is requested
  73437. * @param errorCallback callback call if an error occurs
  73438. */
  73439. 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>);
  73440. private _dragEnterHandler;
  73441. private _dragOverHandler;
  73442. private _dropHandler;
  73443. /**
  73444. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73445. * @param elementToMonitor defines the DOM element to track
  73446. */
  73447. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73448. /** Gets the current list of files to load */
  73449. get filesToLoad(): File[];
  73450. /**
  73451. * Release all associated resources
  73452. */
  73453. dispose(): void;
  73454. private renderFunction;
  73455. private drag;
  73456. private drop;
  73457. private _traverseFolder;
  73458. private _processFiles;
  73459. /**
  73460. * Load files from a drop event
  73461. * @param event defines the drop event to use as source
  73462. */
  73463. loadFiles(event: any): void;
  73464. private _processReload;
  73465. /**
  73466. * Reload the current scene from the loaded files
  73467. */
  73468. reload(): void;
  73469. }
  73470. }
  73471. declare module BABYLON {
  73472. /**
  73473. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73474. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73475. */
  73476. export class SceneOptimization {
  73477. /**
  73478. * Defines the priority of this optimization (0 by default which means first in the list)
  73479. */
  73480. priority: number;
  73481. /**
  73482. * Gets a string describing the action executed by the current optimization
  73483. * @returns description string
  73484. */
  73485. getDescription(): string;
  73486. /**
  73487. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73488. * @param scene defines the current scene where to apply this optimization
  73489. * @param optimizer defines the current optimizer
  73490. * @returns true if everything that can be done was applied
  73491. */
  73492. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73493. /**
  73494. * Creates the SceneOptimization object
  73495. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73496. * @param desc defines the description associated with the optimization
  73497. */
  73498. constructor(
  73499. /**
  73500. * Defines the priority of this optimization (0 by default which means first in the list)
  73501. */
  73502. priority?: number);
  73503. }
  73504. /**
  73505. * Defines an optimization used to reduce the size of render target textures
  73506. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73507. */
  73508. export class TextureOptimization extends SceneOptimization {
  73509. /**
  73510. * Defines the priority of this optimization (0 by default which means first in the list)
  73511. */
  73512. priority: number;
  73513. /**
  73514. * 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
  73515. */
  73516. maximumSize: number;
  73517. /**
  73518. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73519. */
  73520. step: number;
  73521. /**
  73522. * Gets a string describing the action executed by the current optimization
  73523. * @returns description string
  73524. */
  73525. getDescription(): string;
  73526. /**
  73527. * Creates the TextureOptimization object
  73528. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73529. * @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
  73530. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73531. */
  73532. constructor(
  73533. /**
  73534. * Defines the priority of this optimization (0 by default which means first in the list)
  73535. */
  73536. priority?: number,
  73537. /**
  73538. * 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
  73539. */
  73540. maximumSize?: number,
  73541. /**
  73542. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73543. */
  73544. step?: number);
  73545. /**
  73546. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73547. * @param scene defines the current scene where to apply this optimization
  73548. * @param optimizer defines the current optimizer
  73549. * @returns true if everything that can be done was applied
  73550. */
  73551. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73552. }
  73553. /**
  73554. * Defines an optimization used to increase or decrease the rendering resolution
  73555. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73556. */
  73557. export class HardwareScalingOptimization extends SceneOptimization {
  73558. /**
  73559. * Defines the priority of this optimization (0 by default which means first in the list)
  73560. */
  73561. priority: number;
  73562. /**
  73563. * Defines the maximum scale to use (2 by default)
  73564. */
  73565. maximumScale: number;
  73566. /**
  73567. * Defines the step to use between two passes (0.5 by default)
  73568. */
  73569. step: number;
  73570. private _currentScale;
  73571. private _directionOffset;
  73572. /**
  73573. * Gets a string describing the action executed by the current optimization
  73574. * @return description string
  73575. */
  73576. getDescription(): string;
  73577. /**
  73578. * Creates the HardwareScalingOptimization object
  73579. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73580. * @param maximumScale defines the maximum scale to use (2 by default)
  73581. * @param step defines the step to use between two passes (0.5 by default)
  73582. */
  73583. constructor(
  73584. /**
  73585. * Defines the priority of this optimization (0 by default which means first in the list)
  73586. */
  73587. priority?: number,
  73588. /**
  73589. * Defines the maximum scale to use (2 by default)
  73590. */
  73591. maximumScale?: number,
  73592. /**
  73593. * Defines the step to use between two passes (0.5 by default)
  73594. */
  73595. step?: number);
  73596. /**
  73597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73598. * @param scene defines the current scene where to apply this optimization
  73599. * @param optimizer defines the current optimizer
  73600. * @returns true if everything that can be done was applied
  73601. */
  73602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73603. }
  73604. /**
  73605. * Defines an optimization used to remove shadows
  73606. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73607. */
  73608. export class ShadowsOptimization extends SceneOptimization {
  73609. /**
  73610. * Gets a string describing the action executed by the current optimization
  73611. * @return description string
  73612. */
  73613. getDescription(): string;
  73614. /**
  73615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73616. * @param scene defines the current scene where to apply this optimization
  73617. * @param optimizer defines the current optimizer
  73618. * @returns true if everything that can be done was applied
  73619. */
  73620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73621. }
  73622. /**
  73623. * Defines an optimization used to turn post-processes off
  73624. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73625. */
  73626. export class PostProcessesOptimization extends SceneOptimization {
  73627. /**
  73628. * Gets a string describing the action executed by the current optimization
  73629. * @return description string
  73630. */
  73631. getDescription(): string;
  73632. /**
  73633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73634. * @param scene defines the current scene where to apply this optimization
  73635. * @param optimizer defines the current optimizer
  73636. * @returns true if everything that can be done was applied
  73637. */
  73638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73639. }
  73640. /**
  73641. * Defines an optimization used to turn lens flares off
  73642. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73643. */
  73644. export class LensFlaresOptimization extends SceneOptimization {
  73645. /**
  73646. * Gets a string describing the action executed by the current optimization
  73647. * @return description string
  73648. */
  73649. getDescription(): string;
  73650. /**
  73651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73652. * @param scene defines the current scene where to apply this optimization
  73653. * @param optimizer defines the current optimizer
  73654. * @returns true if everything that can be done was applied
  73655. */
  73656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73657. }
  73658. /**
  73659. * Defines an optimization based on user defined callback.
  73660. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73661. */
  73662. export class CustomOptimization extends SceneOptimization {
  73663. /**
  73664. * Callback called to apply the custom optimization.
  73665. */
  73666. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73667. /**
  73668. * Callback called to get custom description
  73669. */
  73670. onGetDescription: () => string;
  73671. /**
  73672. * Gets a string describing the action executed by the current optimization
  73673. * @returns description string
  73674. */
  73675. getDescription(): string;
  73676. /**
  73677. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73678. * @param scene defines the current scene where to apply this optimization
  73679. * @param optimizer defines the current optimizer
  73680. * @returns true if everything that can be done was applied
  73681. */
  73682. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73683. }
  73684. /**
  73685. * Defines an optimization used to turn particles off
  73686. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73687. */
  73688. export class ParticlesOptimization extends SceneOptimization {
  73689. /**
  73690. * Gets a string describing the action executed by the current optimization
  73691. * @return description string
  73692. */
  73693. getDescription(): string;
  73694. /**
  73695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73696. * @param scene defines the current scene where to apply this optimization
  73697. * @param optimizer defines the current optimizer
  73698. * @returns true if everything that can be done was applied
  73699. */
  73700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73701. }
  73702. /**
  73703. * Defines an optimization used to turn render targets off
  73704. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73705. */
  73706. export class RenderTargetsOptimization extends SceneOptimization {
  73707. /**
  73708. * Gets a string describing the action executed by the current optimization
  73709. * @return description string
  73710. */
  73711. getDescription(): string;
  73712. /**
  73713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73714. * @param scene defines the current scene where to apply this optimization
  73715. * @param optimizer defines the current optimizer
  73716. * @returns true if everything that can be done was applied
  73717. */
  73718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73719. }
  73720. /**
  73721. * Defines an optimization used to merge meshes with compatible materials
  73722. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73723. */
  73724. export class MergeMeshesOptimization extends SceneOptimization {
  73725. private static _UpdateSelectionTree;
  73726. /**
  73727. * Gets or sets a boolean which defines if optimization octree has to be updated
  73728. */
  73729. static get UpdateSelectionTree(): boolean;
  73730. /**
  73731. * Gets or sets a boolean which defines if optimization octree has to be updated
  73732. */
  73733. static set UpdateSelectionTree(value: boolean);
  73734. /**
  73735. * Gets a string describing the action executed by the current optimization
  73736. * @return description string
  73737. */
  73738. getDescription(): string;
  73739. private _canBeMerged;
  73740. /**
  73741. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73742. * @param scene defines the current scene where to apply this optimization
  73743. * @param optimizer defines the current optimizer
  73744. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73745. * @returns true if everything that can be done was applied
  73746. */
  73747. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73748. }
  73749. /**
  73750. * Defines a list of options used by SceneOptimizer
  73751. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73752. */
  73753. export class SceneOptimizerOptions {
  73754. /**
  73755. * Defines the target frame rate to reach (60 by default)
  73756. */
  73757. targetFrameRate: number;
  73758. /**
  73759. * Defines the interval between two checkes (2000ms by default)
  73760. */
  73761. trackerDuration: number;
  73762. /**
  73763. * Gets the list of optimizations to apply
  73764. */
  73765. optimizations: SceneOptimization[];
  73766. /**
  73767. * Creates a new list of options used by SceneOptimizer
  73768. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73769. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73770. */
  73771. constructor(
  73772. /**
  73773. * Defines the target frame rate to reach (60 by default)
  73774. */
  73775. targetFrameRate?: number,
  73776. /**
  73777. * Defines the interval between two checkes (2000ms by default)
  73778. */
  73779. trackerDuration?: number);
  73780. /**
  73781. * Add a new optimization
  73782. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73783. * @returns the current SceneOptimizerOptions
  73784. */
  73785. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73786. /**
  73787. * Add a new custom optimization
  73788. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73789. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73790. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73791. * @returns the current SceneOptimizerOptions
  73792. */
  73793. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73794. /**
  73795. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73796. * @param targetFrameRate defines the target frame rate (60 by default)
  73797. * @returns a SceneOptimizerOptions object
  73798. */
  73799. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73800. /**
  73801. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73802. * @param targetFrameRate defines the target frame rate (60 by default)
  73803. * @returns a SceneOptimizerOptions object
  73804. */
  73805. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73806. /**
  73807. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73808. * @param targetFrameRate defines the target frame rate (60 by default)
  73809. * @returns a SceneOptimizerOptions object
  73810. */
  73811. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73812. }
  73813. /**
  73814. * Class used to run optimizations in order to reach a target frame rate
  73815. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73816. */
  73817. export class SceneOptimizer implements IDisposable {
  73818. private _isRunning;
  73819. private _options;
  73820. private _scene;
  73821. private _currentPriorityLevel;
  73822. private _targetFrameRate;
  73823. private _trackerDuration;
  73824. private _currentFrameRate;
  73825. private _sceneDisposeObserver;
  73826. private _improvementMode;
  73827. /**
  73828. * Defines an observable called when the optimizer reaches the target frame rate
  73829. */
  73830. onSuccessObservable: Observable<SceneOptimizer>;
  73831. /**
  73832. * Defines an observable called when the optimizer enables an optimization
  73833. */
  73834. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73835. /**
  73836. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73837. */
  73838. onFailureObservable: Observable<SceneOptimizer>;
  73839. /**
  73840. * Gets a boolean indicating if the optimizer is in improvement mode
  73841. */
  73842. get isInImprovementMode(): boolean;
  73843. /**
  73844. * Gets the current priority level (0 at start)
  73845. */
  73846. get currentPriorityLevel(): number;
  73847. /**
  73848. * Gets the current frame rate checked by the SceneOptimizer
  73849. */
  73850. get currentFrameRate(): number;
  73851. /**
  73852. * Gets or sets the current target frame rate (60 by default)
  73853. */
  73854. get targetFrameRate(): number;
  73855. /**
  73856. * Gets or sets the current target frame rate (60 by default)
  73857. */
  73858. set targetFrameRate(value: number);
  73859. /**
  73860. * Gets or sets the current interval between two checks (every 2000ms by default)
  73861. */
  73862. get trackerDuration(): number;
  73863. /**
  73864. * Gets or sets the current interval between two checks (every 2000ms by default)
  73865. */
  73866. set trackerDuration(value: number);
  73867. /**
  73868. * Gets the list of active optimizations
  73869. */
  73870. get optimizations(): SceneOptimization[];
  73871. /**
  73872. * Creates a new SceneOptimizer
  73873. * @param scene defines the scene to work on
  73874. * @param options defines the options to use with the SceneOptimizer
  73875. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73876. * @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)
  73877. */
  73878. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73879. /**
  73880. * Stops the current optimizer
  73881. */
  73882. stop(): void;
  73883. /**
  73884. * Reset the optimizer to initial step (current priority level = 0)
  73885. */
  73886. reset(): void;
  73887. /**
  73888. * Start the optimizer. By default it will try to reach a specific framerate
  73889. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73890. */
  73891. start(): void;
  73892. private _checkCurrentState;
  73893. /**
  73894. * Release all resources
  73895. */
  73896. dispose(): void;
  73897. /**
  73898. * Helper function to create a SceneOptimizer with one single line of code
  73899. * @param scene defines the scene to work on
  73900. * @param options defines the options to use with the SceneOptimizer
  73901. * @param onSuccess defines a callback to call on success
  73902. * @param onFailure defines a callback to call on failure
  73903. * @returns the new SceneOptimizer object
  73904. */
  73905. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73906. }
  73907. }
  73908. declare module BABYLON {
  73909. /**
  73910. * Class used to serialize a scene into a string
  73911. */
  73912. export class SceneSerializer {
  73913. /**
  73914. * Clear cache used by a previous serialization
  73915. */
  73916. static ClearCache(): void;
  73917. /**
  73918. * Serialize a scene into a JSON compatible object
  73919. * @param scene defines the scene to serialize
  73920. * @returns a JSON compatible object
  73921. */
  73922. static Serialize(scene: Scene): any;
  73923. /**
  73924. * Serialize a mesh into a JSON compatible object
  73925. * @param toSerialize defines the mesh to serialize
  73926. * @param withParents defines if parents must be serialized as well
  73927. * @param withChildren defines if children must be serialized as well
  73928. * @returns a JSON compatible object
  73929. */
  73930. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73931. }
  73932. }
  73933. declare module BABYLON {
  73934. /**
  73935. * Class used to host texture specific utilities
  73936. */
  73937. export class TextureTools {
  73938. /**
  73939. * Uses the GPU to create a copy texture rescaled at a given size
  73940. * @param texture Texture to copy from
  73941. * @param width defines the desired width
  73942. * @param height defines the desired height
  73943. * @param useBilinearMode defines if bilinear mode has to be used
  73944. * @return the generated texture
  73945. */
  73946. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73947. }
  73948. }
  73949. declare module BABYLON {
  73950. /**
  73951. * This represents the different options available for the video capture.
  73952. */
  73953. export interface VideoRecorderOptions {
  73954. /** Defines the mime type of the video. */
  73955. mimeType: string;
  73956. /** Defines the FPS the video should be recorded at. */
  73957. fps: number;
  73958. /** Defines the chunk size for the recording data. */
  73959. recordChunckSize: number;
  73960. /** The audio tracks to attach to the recording. */
  73961. audioTracks?: MediaStreamTrack[];
  73962. }
  73963. /**
  73964. * This can help with recording videos from BabylonJS.
  73965. * This is based on the available WebRTC functionalities of the browser.
  73966. *
  73967. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73968. */
  73969. export class VideoRecorder {
  73970. private static readonly _defaultOptions;
  73971. /**
  73972. * Returns whether or not the VideoRecorder is available in your browser.
  73973. * @param engine Defines the Babylon Engine.
  73974. * @returns true if supported otherwise false.
  73975. */
  73976. static IsSupported(engine: Engine): boolean;
  73977. private readonly _options;
  73978. private _canvas;
  73979. private _mediaRecorder;
  73980. private _recordedChunks;
  73981. private _fileName;
  73982. private _resolve;
  73983. private _reject;
  73984. /**
  73985. * True when a recording is already in progress.
  73986. */
  73987. get isRecording(): boolean;
  73988. /**
  73989. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73990. * @param engine Defines the BabylonJS Engine you wish to record.
  73991. * @param options Defines options that can be used to customize the capture.
  73992. */
  73993. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73994. /**
  73995. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73996. */
  73997. stopRecording(): void;
  73998. /**
  73999. * Starts recording the canvas for a max duration specified in parameters.
  74000. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74001. * If null no automatic download will start and you can rely on the promise to get the data back.
  74002. * @param maxDuration Defines the maximum recording time in seconds.
  74003. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74004. * @return A promise callback at the end of the recording with the video data in Blob.
  74005. */
  74006. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74007. /**
  74008. * Releases internal resources used during the recording.
  74009. */
  74010. dispose(): void;
  74011. private _handleDataAvailable;
  74012. private _handleError;
  74013. private _handleStop;
  74014. }
  74015. }
  74016. declare module BABYLON {
  74017. /**
  74018. * Class containing a set of static utilities functions for screenshots
  74019. */
  74020. export class ScreenshotTools {
  74021. /**
  74022. * Captures a screenshot of the current rendering
  74023. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74024. * @param engine defines the rendering engine
  74025. * @param camera defines the source camera
  74026. * @param size This parameter can be set to a single number or to an object with the
  74027. * following (optional) properties: precision, width, height. If a single number is passed,
  74028. * it will be used for both width and height. If an object is passed, the screenshot size
  74029. * will be derived from the parameters. The precision property is a multiplier allowing
  74030. * rendering at a higher or lower resolution
  74031. * @param successCallback defines the callback receives a single parameter which contains the
  74032. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74033. * src parameter of an <img> to display it
  74034. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74035. * Check your browser for supported MIME types
  74036. */
  74037. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74038. /**
  74039. * Captures a screenshot of the current rendering
  74040. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74041. * @param engine defines the rendering engine
  74042. * @param camera defines the source camera
  74043. * @param size This parameter can be set to a single number or to an object with the
  74044. * following (optional) properties: precision, width, height. If a single number is passed,
  74045. * it will be used for both width and height. If an object is passed, the screenshot size
  74046. * will be derived from the parameters. The precision property is a multiplier allowing
  74047. * rendering at a higher or lower resolution
  74048. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74049. * Check your browser for supported MIME types
  74050. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74051. * to the src parameter of an <img> to display it
  74052. */
  74053. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74054. /**
  74055. * Generates an image screenshot from the specified camera.
  74056. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74057. * @param engine The engine to use for rendering
  74058. * @param camera The camera to use for rendering
  74059. * @param size This parameter can be set to a single number or to an object with the
  74060. * following (optional) properties: precision, width, height. If a single number is passed,
  74061. * it will be used for both width and height. If an object is passed, the screenshot size
  74062. * will be derived from the parameters. The precision property is a multiplier allowing
  74063. * rendering at a higher or lower resolution
  74064. * @param successCallback The callback receives a single parameter which contains the
  74065. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74066. * src parameter of an <img> to display it
  74067. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74068. * Check your browser for supported MIME types
  74069. * @param samples Texture samples (default: 1)
  74070. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74071. * @param fileName A name for for the downloaded file.
  74072. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74073. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74074. */
  74075. 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;
  74076. /**
  74077. * Generates an image screenshot from the specified camera.
  74078. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74079. * @param engine The engine to use for rendering
  74080. * @param camera The camera to use for rendering
  74081. * @param size This parameter can be set to a single number or to an object with the
  74082. * following (optional) properties: precision, width, height. If a single number is passed,
  74083. * it will be used for both width and height. If an object is passed, the screenshot size
  74084. * will be derived from the parameters. The precision property is a multiplier allowing
  74085. * rendering at a higher or lower resolution
  74086. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74087. * Check your browser for supported MIME types
  74088. * @param samples Texture samples (default: 1)
  74089. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74090. * @param fileName A name for for the downloaded file.
  74091. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74092. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74093. * to the src parameter of an <img> to display it
  74094. */
  74095. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74096. /**
  74097. * Gets height and width for screenshot size
  74098. * @private
  74099. */
  74100. private static _getScreenshotSize;
  74101. }
  74102. }
  74103. declare module BABYLON {
  74104. /**
  74105. * Interface for a data buffer
  74106. */
  74107. export interface IDataBuffer {
  74108. /**
  74109. * Reads bytes from the data buffer.
  74110. * @param byteOffset The byte offset to read
  74111. * @param byteLength The byte length to read
  74112. * @returns A promise that resolves when the bytes are read
  74113. */
  74114. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74115. /**
  74116. * The byte length of the buffer.
  74117. */
  74118. readonly byteLength: number;
  74119. }
  74120. /**
  74121. * Utility class for reading from a data buffer
  74122. */
  74123. export class DataReader {
  74124. /**
  74125. * The data buffer associated with this data reader.
  74126. */
  74127. readonly buffer: IDataBuffer;
  74128. /**
  74129. * The current byte offset from the beginning of the data buffer.
  74130. */
  74131. byteOffset: number;
  74132. private _dataView;
  74133. private _dataByteOffset;
  74134. /**
  74135. * Constructor
  74136. * @param buffer The buffer to read
  74137. */
  74138. constructor(buffer: IDataBuffer);
  74139. /**
  74140. * Loads the given byte length.
  74141. * @param byteLength The byte length to load
  74142. * @returns A promise that resolves when the load is complete
  74143. */
  74144. loadAsync(byteLength: number): Promise<void>;
  74145. /**
  74146. * Read a unsigned 32-bit integer from the currently loaded data range.
  74147. * @returns The 32-bit integer read
  74148. */
  74149. readUint32(): number;
  74150. /**
  74151. * Read a byte array from the currently loaded data range.
  74152. * @param byteLength The byte length to read
  74153. * @returns The byte array read
  74154. */
  74155. readUint8Array(byteLength: number): Uint8Array;
  74156. /**
  74157. * Read a string from the currently loaded data range.
  74158. * @param byteLength The byte length to read
  74159. * @returns The string read
  74160. */
  74161. readString(byteLength: number): string;
  74162. /**
  74163. * Skips the given byte length the currently loaded data range.
  74164. * @param byteLength The byte length to skip
  74165. */
  74166. skipBytes(byteLength: number): void;
  74167. }
  74168. }
  74169. declare module BABYLON {
  74170. /**
  74171. * Class for storing data to local storage if available or in-memory storage otherwise
  74172. */
  74173. export class DataStorage {
  74174. private static _Storage;
  74175. private static _GetStorage;
  74176. /**
  74177. * Reads a string from the data storage
  74178. * @param key The key to read
  74179. * @param defaultValue The value if the key doesn't exist
  74180. * @returns The string value
  74181. */
  74182. static ReadString(key: string, defaultValue: string): string;
  74183. /**
  74184. * Writes a string to the data storage
  74185. * @param key The key to write
  74186. * @param value The value to write
  74187. */
  74188. static WriteString(key: string, value: string): void;
  74189. /**
  74190. * Reads a boolean from the data storage
  74191. * @param key The key to read
  74192. * @param defaultValue The value if the key doesn't exist
  74193. * @returns The boolean value
  74194. */
  74195. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74196. /**
  74197. * Writes a boolean to the data storage
  74198. * @param key The key to write
  74199. * @param value The value to write
  74200. */
  74201. static WriteBoolean(key: string, value: boolean): void;
  74202. /**
  74203. * Reads a number from the data storage
  74204. * @param key The key to read
  74205. * @param defaultValue The value if the key doesn't exist
  74206. * @returns The number value
  74207. */
  74208. static ReadNumber(key: string, defaultValue: number): number;
  74209. /**
  74210. * Writes a number to the data storage
  74211. * @param key The key to write
  74212. * @param value The value to write
  74213. */
  74214. static WriteNumber(key: string, value: number): void;
  74215. }
  74216. }
  74217. declare module BABYLON {
  74218. /**
  74219. * Class used to record delta files between 2 scene states
  74220. */
  74221. export class SceneRecorder {
  74222. private _trackedScene;
  74223. private _savedJSON;
  74224. /**
  74225. * Track a given scene. This means the current scene state will be considered the original state
  74226. * @param scene defines the scene to track
  74227. */
  74228. track(scene: Scene): void;
  74229. /**
  74230. * Get the delta between current state and original state
  74231. * @returns a string containing the delta
  74232. */
  74233. getDelta(): any;
  74234. private _compareArray;
  74235. private _compareObjects;
  74236. private _compareCollections;
  74237. private static GetShadowGeneratorById;
  74238. /**
  74239. * Apply a given delta to a given scene
  74240. * @param deltaJSON defines the JSON containing the delta
  74241. * @param scene defines the scene to apply the delta to
  74242. */
  74243. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74244. private static _ApplyPropertiesToEntity;
  74245. private static _ApplyDeltaForEntity;
  74246. }
  74247. }
  74248. declare module BABYLON {
  74249. /**
  74250. * An interface for all Hit test features
  74251. */
  74252. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74253. /**
  74254. * Triggered when new babylon (transformed) hit test results are available
  74255. */
  74256. onHitTestResultObservable: Observable<T[]>;
  74257. }
  74258. /**
  74259. * Options used for hit testing
  74260. */
  74261. export interface IWebXRLegacyHitTestOptions {
  74262. /**
  74263. * Only test when user interacted with the scene. Default - hit test every frame
  74264. */
  74265. testOnPointerDownOnly?: boolean;
  74266. /**
  74267. * The node to use to transform the local results to world coordinates
  74268. */
  74269. worldParentNode?: TransformNode;
  74270. }
  74271. /**
  74272. * Interface defining the babylon result of raycasting/hit-test
  74273. */
  74274. export interface IWebXRLegacyHitResult {
  74275. /**
  74276. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74277. */
  74278. transformationMatrix: Matrix;
  74279. /**
  74280. * The native hit test result
  74281. */
  74282. xrHitResult: XRHitResult | XRHitTestResult;
  74283. }
  74284. /**
  74285. * The currently-working hit-test module.
  74286. * Hit test (or Ray-casting) is used to interact with the real world.
  74287. * For further information read here - https://github.com/immersive-web/hit-test
  74288. */
  74289. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74290. /**
  74291. * options to use when constructing this feature
  74292. */
  74293. readonly options: IWebXRLegacyHitTestOptions;
  74294. private _direction;
  74295. private _mat;
  74296. private _onSelectEnabled;
  74297. private _origin;
  74298. /**
  74299. * The module's name
  74300. */
  74301. static readonly Name: string;
  74302. /**
  74303. * The (Babylon) version of this module.
  74304. * This is an integer representing the implementation version.
  74305. * This number does not correspond to the WebXR specs version
  74306. */
  74307. static readonly Version: number;
  74308. /**
  74309. * Populated with the last native XR Hit Results
  74310. */
  74311. lastNativeXRHitResults: XRHitResult[];
  74312. /**
  74313. * Triggered when new babylon (transformed) hit test results are available
  74314. */
  74315. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74316. /**
  74317. * Creates a new instance of the (legacy version) hit test feature
  74318. * @param _xrSessionManager an instance of WebXRSessionManager
  74319. * @param options options to use when constructing this feature
  74320. */
  74321. constructor(_xrSessionManager: WebXRSessionManager,
  74322. /**
  74323. * options to use when constructing this feature
  74324. */
  74325. options?: IWebXRLegacyHitTestOptions);
  74326. /**
  74327. * execute a hit test with an XR Ray
  74328. *
  74329. * @param xrSession a native xrSession that will execute this hit test
  74330. * @param xrRay the ray (position and direction) to use for ray-casting
  74331. * @param referenceSpace native XR reference space to use for the hit-test
  74332. * @param filter filter function that will filter the results
  74333. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74334. */
  74335. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74336. /**
  74337. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74338. * @param event the (select) event to use to select with
  74339. * @param referenceSpace the reference space to use for this hit test
  74340. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74341. */
  74342. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74343. /**
  74344. * attach this feature
  74345. * Will usually be called by the features manager
  74346. *
  74347. * @returns true if successful.
  74348. */
  74349. attach(): boolean;
  74350. /**
  74351. * detach this feature.
  74352. * Will usually be called by the features manager
  74353. *
  74354. * @returns true if successful.
  74355. */
  74356. detach(): boolean;
  74357. /**
  74358. * Dispose this feature and all of the resources attached
  74359. */
  74360. dispose(): void;
  74361. protected _onXRFrame(frame: XRFrame): void;
  74362. private _onHitTestResults;
  74363. private _onSelect;
  74364. }
  74365. }
  74366. declare module BABYLON {
  74367. /**
  74368. * Options used for hit testing (version 2)
  74369. */
  74370. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74371. /**
  74372. * Do not create a permanent hit test. Will usually be used when only
  74373. * transient inputs are needed.
  74374. */
  74375. disablePermanentHitTest?: boolean;
  74376. /**
  74377. * Enable transient (for example touch-based) hit test inspections
  74378. */
  74379. enableTransientHitTest?: boolean;
  74380. /**
  74381. * Offset ray for the permanent hit test
  74382. */
  74383. offsetRay?: Vector3;
  74384. /**
  74385. * Offset ray for the transient hit test
  74386. */
  74387. transientOffsetRay?: Vector3;
  74388. /**
  74389. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74390. */
  74391. useReferenceSpace?: boolean;
  74392. /**
  74393. * Override the default entity type(s) of the hit-test result
  74394. */
  74395. entityTypes?: XRHitTestTrackableType[];
  74396. }
  74397. /**
  74398. * Interface defining the babylon result of hit-test
  74399. */
  74400. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74401. /**
  74402. * The input source that generated this hit test (if transient)
  74403. */
  74404. inputSource?: XRInputSource;
  74405. /**
  74406. * Is this a transient hit test
  74407. */
  74408. isTransient?: boolean;
  74409. /**
  74410. * Position of the hit test result
  74411. */
  74412. position: Vector3;
  74413. /**
  74414. * Rotation of the hit test result
  74415. */
  74416. rotationQuaternion: Quaternion;
  74417. /**
  74418. * The native hit test result
  74419. */
  74420. xrHitResult: XRHitTestResult;
  74421. }
  74422. /**
  74423. * The currently-working hit-test module.
  74424. * Hit test (or Ray-casting) is used to interact with the real world.
  74425. * For further information read here - https://github.com/immersive-web/hit-test
  74426. *
  74427. * Tested on chrome (mobile) 80.
  74428. */
  74429. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74430. /**
  74431. * options to use when constructing this feature
  74432. */
  74433. readonly options: IWebXRHitTestOptions;
  74434. private _tmpMat;
  74435. private _tmpPos;
  74436. private _tmpQuat;
  74437. private _transientXrHitTestSource;
  74438. private _xrHitTestSource;
  74439. private initHitTestSource;
  74440. /**
  74441. * The module's name
  74442. */
  74443. static readonly Name: string;
  74444. /**
  74445. * The (Babylon) version of this module.
  74446. * This is an integer representing the implementation version.
  74447. * This number does not correspond to the WebXR specs version
  74448. */
  74449. static readonly Version: number;
  74450. /**
  74451. * When set to true, each hit test will have its own position/rotation objects
  74452. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74453. * the developers will clone them or copy them as they see fit.
  74454. */
  74455. autoCloneTransformation: boolean;
  74456. /**
  74457. * Triggered when new babylon (transformed) hit test results are available
  74458. */
  74459. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74460. /**
  74461. * Use this to temporarily pause hit test checks.
  74462. */
  74463. paused: boolean;
  74464. /**
  74465. * Creates a new instance of the hit test feature
  74466. * @param _xrSessionManager an instance of WebXRSessionManager
  74467. * @param options options to use when constructing this feature
  74468. */
  74469. constructor(_xrSessionManager: WebXRSessionManager,
  74470. /**
  74471. * options to use when constructing this feature
  74472. */
  74473. options?: IWebXRHitTestOptions);
  74474. /**
  74475. * attach this feature
  74476. * Will usually be called by the features manager
  74477. *
  74478. * @returns true if successful.
  74479. */
  74480. attach(): boolean;
  74481. /**
  74482. * detach this feature.
  74483. * Will usually be called by the features manager
  74484. *
  74485. * @returns true if successful.
  74486. */
  74487. detach(): boolean;
  74488. /**
  74489. * Dispose this feature and all of the resources attached
  74490. */
  74491. dispose(): void;
  74492. protected _onXRFrame(frame: XRFrame): void;
  74493. private _processWebXRHitTestResult;
  74494. }
  74495. }
  74496. declare module BABYLON {
  74497. /**
  74498. * Configuration options of the anchor system
  74499. */
  74500. export interface IWebXRAnchorSystemOptions {
  74501. /**
  74502. * a node that will be used to convert local to world coordinates
  74503. */
  74504. worldParentNode?: TransformNode;
  74505. /**
  74506. * If set to true a reference of the created anchors will be kept until the next session starts
  74507. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74508. */
  74509. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74510. }
  74511. /**
  74512. * A babylon container for an XR Anchor
  74513. */
  74514. export interface IWebXRAnchor {
  74515. /**
  74516. * A babylon-assigned ID for this anchor
  74517. */
  74518. id: number;
  74519. /**
  74520. * Transformation matrix to apply to an object attached to this anchor
  74521. */
  74522. transformationMatrix: Matrix;
  74523. /**
  74524. * The native anchor object
  74525. */
  74526. xrAnchor: XRAnchor;
  74527. /**
  74528. * if defined, this object will be constantly updated by the anchor's position and rotation
  74529. */
  74530. attachedNode?: TransformNode;
  74531. }
  74532. /**
  74533. * An implementation of the anchor system for WebXR.
  74534. * For further information see https://github.com/immersive-web/anchors/
  74535. */
  74536. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74537. private _options;
  74538. private _lastFrameDetected;
  74539. private _trackedAnchors;
  74540. private _referenceSpaceForFrameAnchors;
  74541. private _futureAnchors;
  74542. /**
  74543. * The module's name
  74544. */
  74545. static readonly Name: string;
  74546. /**
  74547. * The (Babylon) version of this module.
  74548. * This is an integer representing the implementation version.
  74549. * This number does not correspond to the WebXR specs version
  74550. */
  74551. static readonly Version: number;
  74552. /**
  74553. * Observers registered here will be executed when a new anchor was added to the session
  74554. */
  74555. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74556. /**
  74557. * Observers registered here will be executed when an anchor was removed from the session
  74558. */
  74559. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74560. /**
  74561. * Observers registered here will be executed when an existing anchor updates
  74562. * This can execute N times every frame
  74563. */
  74564. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74565. /**
  74566. * Set the reference space to use for anchor creation, when not using a hit test.
  74567. * Will default to the session's reference space if not defined
  74568. */
  74569. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74570. /**
  74571. * constructs a new anchor system
  74572. * @param _xrSessionManager an instance of WebXRSessionManager
  74573. * @param _options configuration object for this feature
  74574. */
  74575. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74576. private _tmpVector;
  74577. private _tmpQuaternion;
  74578. private _populateTmpTransformation;
  74579. /**
  74580. * Create a new anchor point using a hit test result at a specific point in the scene
  74581. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74582. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74583. *
  74584. * @param hitTestResult The hit test result to use for this anchor creation
  74585. * @param position an optional position offset for this anchor
  74586. * @param rotationQuaternion an optional rotation offset for this anchor
  74587. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74588. */
  74589. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74590. /**
  74591. * Add a new anchor at a specific position and rotation
  74592. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74593. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74594. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74595. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74596. *
  74597. * @param position the position in which to add an anchor
  74598. * @param rotationQuaternion an optional rotation for the anchor transformation
  74599. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74600. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74601. */
  74602. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74603. /**
  74604. * detach this feature.
  74605. * Will usually be called by the features manager
  74606. *
  74607. * @returns true if successful.
  74608. */
  74609. detach(): boolean;
  74610. /**
  74611. * Dispose this feature and all of the resources attached
  74612. */
  74613. dispose(): void;
  74614. protected _onXRFrame(frame: XRFrame): void;
  74615. /**
  74616. * avoiding using Array.find for global support.
  74617. * @param xrAnchor the plane to find in the array
  74618. */
  74619. private _findIndexInAnchorArray;
  74620. private _updateAnchorWithXRFrame;
  74621. private _createAnchorAtTransformation;
  74622. }
  74623. }
  74624. declare module BABYLON {
  74625. /**
  74626. * Options used in the plane detector module
  74627. */
  74628. export interface IWebXRPlaneDetectorOptions {
  74629. /**
  74630. * The node to use to transform the local results to world coordinates
  74631. */
  74632. worldParentNode?: TransformNode;
  74633. /**
  74634. * If set to true a reference of the created planes will be kept until the next session starts
  74635. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74636. */
  74637. doNotRemovePlanesOnSessionEnded?: boolean;
  74638. }
  74639. /**
  74640. * A babylon interface for a WebXR plane.
  74641. * A Plane is actually a polygon, built from N points in space
  74642. *
  74643. * Supported in chrome 79, not supported in canary 81 ATM
  74644. */
  74645. export interface IWebXRPlane {
  74646. /**
  74647. * a babylon-assigned ID for this polygon
  74648. */
  74649. id: number;
  74650. /**
  74651. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74652. */
  74653. polygonDefinition: Array<Vector3>;
  74654. /**
  74655. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74656. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74657. */
  74658. transformationMatrix: Matrix;
  74659. /**
  74660. * the native xr-plane object
  74661. */
  74662. xrPlane: XRPlane;
  74663. }
  74664. /**
  74665. * The plane detector is used to detect planes in the real world when in AR
  74666. * For more information see https://github.com/immersive-web/real-world-geometry/
  74667. */
  74668. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74669. private _options;
  74670. private _detectedPlanes;
  74671. private _enabled;
  74672. private _lastFrameDetected;
  74673. /**
  74674. * The module's name
  74675. */
  74676. static readonly Name: string;
  74677. /**
  74678. * The (Babylon) version of this module.
  74679. * This is an integer representing the implementation version.
  74680. * This number does not correspond to the WebXR specs version
  74681. */
  74682. static readonly Version: number;
  74683. /**
  74684. * Observers registered here will be executed when a new plane was added to the session
  74685. */
  74686. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74687. /**
  74688. * Observers registered here will be executed when a plane is no longer detected in the session
  74689. */
  74690. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74691. /**
  74692. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74693. * This can execute N times every frame
  74694. */
  74695. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74696. /**
  74697. * construct a new Plane Detector
  74698. * @param _xrSessionManager an instance of xr Session manager
  74699. * @param _options configuration to use when constructing this feature
  74700. */
  74701. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74702. /**
  74703. * detach this feature.
  74704. * Will usually be called by the features manager
  74705. *
  74706. * @returns true if successful.
  74707. */
  74708. detach(): boolean;
  74709. /**
  74710. * Dispose this feature and all of the resources attached
  74711. */
  74712. dispose(): void;
  74713. protected _onXRFrame(frame: XRFrame): void;
  74714. private _init;
  74715. private _updatePlaneWithXRPlane;
  74716. /**
  74717. * avoiding using Array.find for global support.
  74718. * @param xrPlane the plane to find in the array
  74719. */
  74720. private findIndexInPlaneArray;
  74721. }
  74722. }
  74723. declare module BABYLON {
  74724. /**
  74725. * Options interface for the background remover plugin
  74726. */
  74727. export interface IWebXRBackgroundRemoverOptions {
  74728. /**
  74729. * Further background meshes to disable when entering AR
  74730. */
  74731. backgroundMeshes?: AbstractMesh[];
  74732. /**
  74733. * flags to configure the removal of the environment helper.
  74734. * If not set, the entire background will be removed. If set, flags should be set as well.
  74735. */
  74736. environmentHelperRemovalFlags?: {
  74737. /**
  74738. * Should the skybox be removed (default false)
  74739. */
  74740. skyBox?: boolean;
  74741. /**
  74742. * Should the ground be removed (default false)
  74743. */
  74744. ground?: boolean;
  74745. };
  74746. /**
  74747. * don't disable the environment helper
  74748. */
  74749. ignoreEnvironmentHelper?: boolean;
  74750. }
  74751. /**
  74752. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74753. */
  74754. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74755. /**
  74756. * read-only options to be used in this module
  74757. */
  74758. readonly options: IWebXRBackgroundRemoverOptions;
  74759. /**
  74760. * The module's name
  74761. */
  74762. static readonly Name: string;
  74763. /**
  74764. * The (Babylon) version of this module.
  74765. * This is an integer representing the implementation version.
  74766. * This number does not correspond to the WebXR specs version
  74767. */
  74768. static readonly Version: number;
  74769. /**
  74770. * registered observers will be triggered when the background state changes
  74771. */
  74772. onBackgroundStateChangedObservable: Observable<boolean>;
  74773. /**
  74774. * constructs a new background remover module
  74775. * @param _xrSessionManager the session manager for this module
  74776. * @param options read-only options to be used in this module
  74777. */
  74778. constructor(_xrSessionManager: WebXRSessionManager,
  74779. /**
  74780. * read-only options to be used in this module
  74781. */
  74782. options?: IWebXRBackgroundRemoverOptions);
  74783. /**
  74784. * attach this feature
  74785. * Will usually be called by the features manager
  74786. *
  74787. * @returns true if successful.
  74788. */
  74789. attach(): boolean;
  74790. /**
  74791. * detach this feature.
  74792. * Will usually be called by the features manager
  74793. *
  74794. * @returns true if successful.
  74795. */
  74796. detach(): boolean;
  74797. /**
  74798. * Dispose this feature and all of the resources attached
  74799. */
  74800. dispose(): void;
  74801. protected _onXRFrame(_xrFrame: XRFrame): void;
  74802. private _setBackgroundState;
  74803. }
  74804. }
  74805. declare module BABYLON {
  74806. /**
  74807. * Options for the controller physics feature
  74808. */
  74809. export class IWebXRControllerPhysicsOptions {
  74810. /**
  74811. * Should the headset get its own impostor
  74812. */
  74813. enableHeadsetImpostor?: boolean;
  74814. /**
  74815. * Optional parameters for the headset impostor
  74816. */
  74817. headsetImpostorParams?: {
  74818. /**
  74819. * The type of impostor to create. Default is sphere
  74820. */
  74821. impostorType: number;
  74822. /**
  74823. * the size of the impostor. Defaults to 10cm
  74824. */
  74825. impostorSize?: number | {
  74826. width: number;
  74827. height: number;
  74828. depth: number;
  74829. };
  74830. /**
  74831. * Friction definitions
  74832. */
  74833. friction?: number;
  74834. /**
  74835. * Restitution
  74836. */
  74837. restitution?: number;
  74838. };
  74839. /**
  74840. * The physics properties of the future impostors
  74841. */
  74842. physicsProperties?: {
  74843. /**
  74844. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74845. * Note that this requires a physics engine that supports mesh impostors!
  74846. */
  74847. useControllerMesh?: boolean;
  74848. /**
  74849. * The type of impostor to create. Default is sphere
  74850. */
  74851. impostorType?: number;
  74852. /**
  74853. * the size of the impostor. Defaults to 10cm
  74854. */
  74855. impostorSize?: number | {
  74856. width: number;
  74857. height: number;
  74858. depth: number;
  74859. };
  74860. /**
  74861. * Friction definitions
  74862. */
  74863. friction?: number;
  74864. /**
  74865. * Restitution
  74866. */
  74867. restitution?: number;
  74868. };
  74869. /**
  74870. * the xr input to use with this pointer selection
  74871. */
  74872. xrInput: WebXRInput;
  74873. }
  74874. /**
  74875. * Add physics impostor to your webxr controllers,
  74876. * including naive calculation of their linear and angular velocity
  74877. */
  74878. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74879. private readonly _options;
  74880. private _attachController;
  74881. private _controllers;
  74882. private _debugMode;
  74883. private _delta;
  74884. private _headsetImpostor?;
  74885. private _headsetMesh?;
  74886. private _lastTimestamp;
  74887. private _tmpQuaternion;
  74888. private _tmpVector;
  74889. /**
  74890. * The module's name
  74891. */
  74892. static readonly Name: string;
  74893. /**
  74894. * The (Babylon) version of this module.
  74895. * This is an integer representing the implementation version.
  74896. * This number does not correspond to the webxr specs version
  74897. */
  74898. static readonly Version: number;
  74899. /**
  74900. * Construct a new Controller Physics Feature
  74901. * @param _xrSessionManager the corresponding xr session manager
  74902. * @param _options options to create this feature with
  74903. */
  74904. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74905. /**
  74906. * @hidden
  74907. * enable debugging - will show console outputs and the impostor mesh
  74908. */
  74909. _enablePhysicsDebug(): void;
  74910. /**
  74911. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74912. * @param xrController the controller to add
  74913. */
  74914. addController(xrController: WebXRInputSource): void;
  74915. /**
  74916. * attach this feature
  74917. * Will usually be called by the features manager
  74918. *
  74919. * @returns true if successful.
  74920. */
  74921. attach(): boolean;
  74922. /**
  74923. * detach this feature.
  74924. * Will usually be called by the features manager
  74925. *
  74926. * @returns true if successful.
  74927. */
  74928. detach(): boolean;
  74929. /**
  74930. * Get the headset impostor, if enabled
  74931. * @returns the impostor
  74932. */
  74933. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74934. /**
  74935. * Get the physics impostor of a specific controller.
  74936. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74937. * @param controller the controller or the controller id of which to get the impostor
  74938. * @returns the impostor or null
  74939. */
  74940. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74941. /**
  74942. * Update the physics properties provided in the constructor
  74943. * @param newProperties the new properties object
  74944. */
  74945. setPhysicsProperties(newProperties: {
  74946. impostorType?: number;
  74947. impostorSize?: number | {
  74948. width: number;
  74949. height: number;
  74950. depth: number;
  74951. };
  74952. friction?: number;
  74953. restitution?: number;
  74954. }): void;
  74955. protected _onXRFrame(_xrFrame: any): void;
  74956. private _detachController;
  74957. }
  74958. }
  74959. declare module BABYLON {
  74960. /**
  74961. * A babylon interface for a "WebXR" feature point.
  74962. * Represents the position and confidence value of a given feature point.
  74963. */
  74964. export interface IWebXRFeaturePoint {
  74965. /**
  74966. * Represents the position of the feature point in world space.
  74967. */
  74968. position: Vector3;
  74969. /**
  74970. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  74971. */
  74972. confidenceValue: number;
  74973. }
  74974. /**
  74975. * The feature point system is used to detect feature points from real world geometry.
  74976. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  74977. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  74978. */
  74979. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  74980. private _enabled;
  74981. private _featurePointCloud;
  74982. /**
  74983. * The module's name
  74984. */
  74985. static readonly Name: string;
  74986. /**
  74987. * The (Babylon) version of this module.
  74988. * This is an integer representing the implementation version.
  74989. * This number does not correspond to the WebXR specs version
  74990. */
  74991. static readonly Version: number;
  74992. /**
  74993. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  74994. * Will notify the observers about which feature points have been added.
  74995. */
  74996. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  74997. /**
  74998. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  74999. * Will notify the observers about which feature points have been updated.
  75000. */
  75001. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75002. /**
  75003. * The current feature point cloud maintained across frames.
  75004. */
  75005. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75006. /**
  75007. * construct the feature point system
  75008. * @param _xrSessionManager an instance of xr Session manager
  75009. */
  75010. constructor(_xrSessionManager: WebXRSessionManager);
  75011. /**
  75012. * Detach this feature.
  75013. * Will usually be called by the features manager
  75014. *
  75015. * @returns true if successful.
  75016. */
  75017. detach(): boolean;
  75018. /**
  75019. * Dispose this feature and all of the resources attached
  75020. */
  75021. dispose(): void;
  75022. /**
  75023. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75024. */
  75025. protected _onXRFrame(frame: XRFrame): void;
  75026. /**
  75027. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75028. */
  75029. private _init;
  75030. }
  75031. }
  75032. declare module BABYLON {
  75033. /**
  75034. * Configuration interface for the hand tracking feature
  75035. */
  75036. export interface IWebXRHandTrackingOptions {
  75037. /**
  75038. * The xrInput that will be used as source for new hands
  75039. */
  75040. xrInput: WebXRInput;
  75041. /**
  75042. * Configuration object for the joint meshes
  75043. */
  75044. jointMeshes?: {
  75045. /**
  75046. * Should the meshes created be invisible (defaults to false)
  75047. */
  75048. invisible?: boolean;
  75049. /**
  75050. * A source mesh to be used to create instances. Defaults to a sphere.
  75051. * This mesh will be the source for all other (25) meshes.
  75052. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75053. */
  75054. sourceMesh?: Mesh;
  75055. /**
  75056. * Should the source mesh stay visible. Defaults to false
  75057. */
  75058. keepOriginalVisible?: boolean;
  75059. /**
  75060. * Scale factor for all instances (defaults to 2)
  75061. */
  75062. scaleFactor?: number;
  75063. /**
  75064. * Should each instance have its own physics impostor
  75065. */
  75066. enablePhysics?: boolean;
  75067. /**
  75068. * If enabled, override default physics properties
  75069. */
  75070. physicsProps?: {
  75071. friction?: number;
  75072. restitution?: number;
  75073. impostorType?: number;
  75074. };
  75075. /**
  75076. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75077. */
  75078. handMesh?: AbstractMesh;
  75079. };
  75080. }
  75081. /**
  75082. * Parts of the hands divided to writs and finger names
  75083. */
  75084. export const enum HandPart {
  75085. /**
  75086. * HandPart - Wrist
  75087. */
  75088. WRIST = "wrist",
  75089. /**
  75090. * HandPart - The THumb
  75091. */
  75092. THUMB = "thumb",
  75093. /**
  75094. * HandPart - Index finger
  75095. */
  75096. INDEX = "index",
  75097. /**
  75098. * HandPart - Middle finger
  75099. */
  75100. MIDDLE = "middle",
  75101. /**
  75102. * HandPart - Ring finger
  75103. */
  75104. RING = "ring",
  75105. /**
  75106. * HandPart - Little finger
  75107. */
  75108. LITTLE = "little"
  75109. }
  75110. /**
  75111. * Representing a single hand (with its corresponding native XRHand object)
  75112. */
  75113. export class WebXRHand implements IDisposable {
  75114. /** the controller to which the hand correlates */
  75115. readonly xrController: WebXRInputSource;
  75116. /** the meshes to be used to track the hand joints */
  75117. readonly trackedMeshes: AbstractMesh[];
  75118. /**
  75119. * Hand-parts definition (key is HandPart)
  75120. */
  75121. handPartsDefinition: {
  75122. [key: string]: number[];
  75123. };
  75124. /**
  75125. * Populate the HandPartsDefinition object.
  75126. * This is called as a side effect since certain browsers don't have XRHand defined.
  75127. */
  75128. private generateHandPartsDefinition;
  75129. /**
  75130. * Construct a new hand object
  75131. * @param xrController the controller to which the hand correlates
  75132. * @param trackedMeshes the meshes to be used to track the hand joints
  75133. */
  75134. constructor(
  75135. /** the controller to which the hand correlates */
  75136. xrController: WebXRInputSource,
  75137. /** the meshes to be used to track the hand joints */
  75138. trackedMeshes: AbstractMesh[]);
  75139. /**
  75140. * Update this hand from the latest xr frame
  75141. * @param xrFrame xrFrame to update from
  75142. * @param referenceSpace The current viewer reference space
  75143. * @param scaleFactor optional scale factor for the meshes
  75144. */
  75145. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75146. /**
  75147. * Get meshes of part of the hand
  75148. * @param part the part of hand to get
  75149. * @returns An array of meshes that correlate to the hand part requested
  75150. */
  75151. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75152. /**
  75153. * Dispose this Hand object
  75154. */
  75155. dispose(): void;
  75156. }
  75157. /**
  75158. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75159. */
  75160. export class WebXRHandTracking extends WebXRAbstractFeature {
  75161. /**
  75162. * options to use when constructing this feature
  75163. */
  75164. readonly options: IWebXRHandTrackingOptions;
  75165. private static _idCounter;
  75166. /**
  75167. * The module's name
  75168. */
  75169. static readonly Name: string;
  75170. /**
  75171. * The (Babylon) version of this module.
  75172. * This is an integer representing the implementation version.
  75173. * This number does not correspond to the WebXR specs version
  75174. */
  75175. static readonly Version: number;
  75176. /**
  75177. * This observable will notify registered observers when a new hand object was added and initialized
  75178. */
  75179. onHandAddedObservable: Observable<WebXRHand>;
  75180. /**
  75181. * This observable will notify its observers right before the hand object is disposed
  75182. */
  75183. onHandRemovedObservable: Observable<WebXRHand>;
  75184. private _hands;
  75185. /**
  75186. * Creates a new instance of the hit test feature
  75187. * @param _xrSessionManager an instance of WebXRSessionManager
  75188. * @param options options to use when constructing this feature
  75189. */
  75190. constructor(_xrSessionManager: WebXRSessionManager,
  75191. /**
  75192. * options to use when constructing this feature
  75193. */
  75194. options: IWebXRHandTrackingOptions);
  75195. /**
  75196. * Check if the needed objects are defined.
  75197. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75198. */
  75199. isCompatible(): boolean;
  75200. /**
  75201. * attach this feature
  75202. * Will usually be called by the features manager
  75203. *
  75204. * @returns true if successful.
  75205. */
  75206. attach(): boolean;
  75207. /**
  75208. * detach this feature.
  75209. * Will usually be called by the features manager
  75210. *
  75211. * @returns true if successful.
  75212. */
  75213. detach(): boolean;
  75214. /**
  75215. * Dispose this feature and all of the resources attached
  75216. */
  75217. dispose(): void;
  75218. /**
  75219. * Get the hand object according to the controller id
  75220. * @param controllerId the controller id to which we want to get the hand
  75221. * @returns null if not found or the WebXRHand object if found
  75222. */
  75223. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75224. /**
  75225. * Get a hand object according to the requested handedness
  75226. * @param handedness the handedness to request
  75227. * @returns null if not found or the WebXRHand object if found
  75228. */
  75229. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75230. protected _onXRFrame(_xrFrame: XRFrame): void;
  75231. private _attachHand;
  75232. private _detachHand;
  75233. }
  75234. }
  75235. declare module BABYLON {
  75236. /**
  75237. * The motion controller class for all microsoft mixed reality controllers
  75238. */
  75239. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75240. protected readonly _mapping: {
  75241. defaultButton: {
  75242. valueNodeName: string;
  75243. unpressedNodeName: string;
  75244. pressedNodeName: string;
  75245. };
  75246. defaultAxis: {
  75247. valueNodeName: string;
  75248. minNodeName: string;
  75249. maxNodeName: string;
  75250. };
  75251. buttons: {
  75252. "xr-standard-trigger": {
  75253. rootNodeName: string;
  75254. componentProperty: string;
  75255. states: string[];
  75256. };
  75257. "xr-standard-squeeze": {
  75258. rootNodeName: string;
  75259. componentProperty: string;
  75260. states: string[];
  75261. };
  75262. "xr-standard-touchpad": {
  75263. rootNodeName: string;
  75264. labelAnchorNodeName: string;
  75265. touchPointNodeName: string;
  75266. };
  75267. "xr-standard-thumbstick": {
  75268. rootNodeName: string;
  75269. componentProperty: string;
  75270. states: string[];
  75271. };
  75272. };
  75273. axes: {
  75274. "xr-standard-touchpad": {
  75275. "x-axis": {
  75276. rootNodeName: string;
  75277. };
  75278. "y-axis": {
  75279. rootNodeName: string;
  75280. };
  75281. };
  75282. "xr-standard-thumbstick": {
  75283. "x-axis": {
  75284. rootNodeName: string;
  75285. };
  75286. "y-axis": {
  75287. rootNodeName: string;
  75288. };
  75289. };
  75290. };
  75291. };
  75292. /**
  75293. * The base url used to load the left and right controller models
  75294. */
  75295. static MODEL_BASE_URL: string;
  75296. /**
  75297. * The name of the left controller model file
  75298. */
  75299. static MODEL_LEFT_FILENAME: string;
  75300. /**
  75301. * The name of the right controller model file
  75302. */
  75303. static MODEL_RIGHT_FILENAME: string;
  75304. profileId: string;
  75305. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75306. protected _getFilenameAndPath(): {
  75307. filename: string;
  75308. path: string;
  75309. };
  75310. protected _getModelLoadingConstraints(): boolean;
  75311. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75312. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75313. protected _updateModel(): void;
  75314. }
  75315. }
  75316. declare module BABYLON {
  75317. /**
  75318. * The motion controller class for oculus touch (quest, rift).
  75319. * This class supports legacy mapping as well the standard xr mapping
  75320. */
  75321. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75322. private _forceLegacyControllers;
  75323. private _modelRootNode;
  75324. /**
  75325. * The base url used to load the left and right controller models
  75326. */
  75327. static MODEL_BASE_URL: string;
  75328. /**
  75329. * The name of the left controller model file
  75330. */
  75331. static MODEL_LEFT_FILENAME: string;
  75332. /**
  75333. * The name of the right controller model file
  75334. */
  75335. static MODEL_RIGHT_FILENAME: string;
  75336. /**
  75337. * Base Url for the Quest controller model.
  75338. */
  75339. static QUEST_MODEL_BASE_URL: string;
  75340. profileId: string;
  75341. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75342. protected _getFilenameAndPath(): {
  75343. filename: string;
  75344. path: string;
  75345. };
  75346. protected _getModelLoadingConstraints(): boolean;
  75347. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75348. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75349. protected _updateModel(): void;
  75350. /**
  75351. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75352. * between the touch and touch 2.
  75353. */
  75354. private _isQuest;
  75355. }
  75356. }
  75357. declare module BABYLON {
  75358. /**
  75359. * The motion controller class for the standard HTC-Vive controllers
  75360. */
  75361. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75362. private _modelRootNode;
  75363. /**
  75364. * The base url used to load the left and right controller models
  75365. */
  75366. static MODEL_BASE_URL: string;
  75367. /**
  75368. * File name for the controller model.
  75369. */
  75370. static MODEL_FILENAME: string;
  75371. profileId: string;
  75372. /**
  75373. * Create a new Vive motion controller object
  75374. * @param scene the scene to use to create this controller
  75375. * @param gamepadObject the corresponding gamepad object
  75376. * @param handedness the handedness of the controller
  75377. */
  75378. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75379. protected _getFilenameAndPath(): {
  75380. filename: string;
  75381. path: string;
  75382. };
  75383. protected _getModelLoadingConstraints(): boolean;
  75384. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75385. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75386. protected _updateModel(): void;
  75387. }
  75388. }
  75389. declare module BABYLON {
  75390. /**
  75391. * A cursor which tracks a point on a path
  75392. */
  75393. export class PathCursor {
  75394. private path;
  75395. /**
  75396. * Stores path cursor callbacks for when an onchange event is triggered
  75397. */
  75398. private _onchange;
  75399. /**
  75400. * The value of the path cursor
  75401. */
  75402. value: number;
  75403. /**
  75404. * The animation array of the path cursor
  75405. */
  75406. animations: Animation[];
  75407. /**
  75408. * Initializes the path cursor
  75409. * @param path The path to track
  75410. */
  75411. constructor(path: Path2);
  75412. /**
  75413. * Gets the cursor point on the path
  75414. * @returns A point on the path cursor at the cursor location
  75415. */
  75416. getPoint(): Vector3;
  75417. /**
  75418. * Moves the cursor ahead by the step amount
  75419. * @param step The amount to move the cursor forward
  75420. * @returns This path cursor
  75421. */
  75422. moveAhead(step?: number): PathCursor;
  75423. /**
  75424. * Moves the cursor behind by the step amount
  75425. * @param step The amount to move the cursor back
  75426. * @returns This path cursor
  75427. */
  75428. moveBack(step?: number): PathCursor;
  75429. /**
  75430. * Moves the cursor by the step amount
  75431. * If the step amount is greater than one, an exception is thrown
  75432. * @param step The amount to move the cursor
  75433. * @returns This path cursor
  75434. */
  75435. move(step: number): PathCursor;
  75436. /**
  75437. * Ensures that the value is limited between zero and one
  75438. * @returns This path cursor
  75439. */
  75440. private ensureLimits;
  75441. /**
  75442. * Runs onchange callbacks on change (used by the animation engine)
  75443. * @returns This path cursor
  75444. */
  75445. private raiseOnChange;
  75446. /**
  75447. * Executes a function on change
  75448. * @param f A path cursor onchange callback
  75449. * @returns This path cursor
  75450. */
  75451. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75452. }
  75453. }
  75454. declare module BABYLON {
  75455. /** @hidden */
  75456. export var blurPixelShader: {
  75457. name: string;
  75458. shader: string;
  75459. };
  75460. }
  75461. declare module BABYLON {
  75462. /** @hidden */
  75463. export var pointCloudVertexDeclaration: {
  75464. name: string;
  75465. shader: string;
  75466. };
  75467. }
  75468. // Mixins
  75469. interface Window {
  75470. mozIndexedDB: IDBFactory;
  75471. webkitIndexedDB: IDBFactory;
  75472. msIndexedDB: IDBFactory;
  75473. webkitURL: typeof URL;
  75474. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75475. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75476. WebGLRenderingContext: WebGLRenderingContext;
  75477. MSGesture: MSGesture;
  75478. CANNON: any;
  75479. AudioContext: AudioContext;
  75480. webkitAudioContext: AudioContext;
  75481. PointerEvent: any;
  75482. Math: Math;
  75483. Uint8Array: Uint8ArrayConstructor;
  75484. Float32Array: Float32ArrayConstructor;
  75485. mozURL: typeof URL;
  75486. msURL: typeof URL;
  75487. VRFrameData: any; // WebVR, from specs 1.1
  75488. DracoDecoderModule: any;
  75489. setImmediate(handler: (...args: any[]) => void): number;
  75490. }
  75491. interface HTMLCanvasElement {
  75492. requestPointerLock(): void;
  75493. msRequestPointerLock?(): void;
  75494. mozRequestPointerLock?(): void;
  75495. webkitRequestPointerLock?(): void;
  75496. /** Track wether a record is in progress */
  75497. isRecording: boolean;
  75498. /** Capture Stream method defined by some browsers */
  75499. captureStream(fps?: number): MediaStream;
  75500. }
  75501. interface CanvasRenderingContext2D {
  75502. msImageSmoothingEnabled: boolean;
  75503. }
  75504. interface MouseEvent {
  75505. mozMovementX: number;
  75506. mozMovementY: number;
  75507. webkitMovementX: number;
  75508. webkitMovementY: number;
  75509. msMovementX: number;
  75510. msMovementY: number;
  75511. }
  75512. interface Navigator {
  75513. mozGetVRDevices: (any: any) => any;
  75514. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75515. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75516. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75517. webkitGetGamepads(): Gamepad[];
  75518. msGetGamepads(): Gamepad[];
  75519. webkitGamepads(): Gamepad[];
  75520. }
  75521. interface HTMLVideoElement {
  75522. mozSrcObject: any;
  75523. }
  75524. interface Math {
  75525. fround(x: number): number;
  75526. imul(a: number, b: number): number;
  75527. }
  75528. interface WebGLRenderingContext {
  75529. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75530. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75531. vertexAttribDivisor(index: number, divisor: number): void;
  75532. createVertexArray(): any;
  75533. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75534. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75535. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75536. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75537. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75538. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75539. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75540. // Queries
  75541. createQuery(): WebGLQuery;
  75542. deleteQuery(query: WebGLQuery): void;
  75543. beginQuery(target: number, query: WebGLQuery): void;
  75544. endQuery(target: number): void;
  75545. getQueryParameter(query: WebGLQuery, pname: number): any;
  75546. getQuery(target: number, pname: number): any;
  75547. MAX_SAMPLES: number;
  75548. RGBA8: number;
  75549. READ_FRAMEBUFFER: number;
  75550. DRAW_FRAMEBUFFER: number;
  75551. UNIFORM_BUFFER: number;
  75552. HALF_FLOAT_OES: number;
  75553. RGBA16F: number;
  75554. RGBA32F: number;
  75555. R32F: number;
  75556. RG32F: number;
  75557. RGB32F: number;
  75558. R16F: number;
  75559. RG16F: number;
  75560. RGB16F: number;
  75561. RED: number;
  75562. RG: number;
  75563. R8: number;
  75564. RG8: number;
  75565. UNSIGNED_INT_24_8: number;
  75566. DEPTH24_STENCIL8: number;
  75567. MIN: number;
  75568. MAX: number;
  75569. /* Multiple Render Targets */
  75570. drawBuffers(buffers: number[]): void;
  75571. readBuffer(src: number): void;
  75572. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75573. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75574. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75575. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75576. // Occlusion Query
  75577. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75578. ANY_SAMPLES_PASSED: number;
  75579. QUERY_RESULT_AVAILABLE: number;
  75580. QUERY_RESULT: number;
  75581. }
  75582. interface WebGLProgram {
  75583. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75584. }
  75585. interface EXT_disjoint_timer_query {
  75586. QUERY_COUNTER_BITS_EXT: number;
  75587. TIME_ELAPSED_EXT: number;
  75588. TIMESTAMP_EXT: number;
  75589. GPU_DISJOINT_EXT: number;
  75590. QUERY_RESULT_EXT: number;
  75591. QUERY_RESULT_AVAILABLE_EXT: number;
  75592. queryCounterEXT(query: WebGLQuery, target: number): void;
  75593. createQueryEXT(): WebGLQuery;
  75594. beginQueryEXT(target: number, query: WebGLQuery): void;
  75595. endQueryEXT(target: number): void;
  75596. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75597. deleteQueryEXT(query: WebGLQuery): void;
  75598. }
  75599. interface WebGLUniformLocation {
  75600. _currentState: any;
  75601. }
  75602. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75603. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75604. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75605. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75606. interface WebGLRenderingContext {
  75607. readonly RASTERIZER_DISCARD: number;
  75608. readonly DEPTH_COMPONENT24: number;
  75609. readonly TEXTURE_3D: number;
  75610. readonly TEXTURE_2D_ARRAY: number;
  75611. readonly TEXTURE_COMPARE_FUNC: number;
  75612. readonly TEXTURE_COMPARE_MODE: number;
  75613. readonly COMPARE_REF_TO_TEXTURE: number;
  75614. readonly TEXTURE_WRAP_R: number;
  75615. readonly HALF_FLOAT: number;
  75616. readonly RGB8: number;
  75617. readonly RED_INTEGER: number;
  75618. readonly RG_INTEGER: number;
  75619. readonly RGB_INTEGER: number;
  75620. readonly RGBA_INTEGER: number;
  75621. readonly R8_SNORM: number;
  75622. readonly RG8_SNORM: number;
  75623. readonly RGB8_SNORM: number;
  75624. readonly RGBA8_SNORM: number;
  75625. readonly R8I: number;
  75626. readonly RG8I: number;
  75627. readonly RGB8I: number;
  75628. readonly RGBA8I: number;
  75629. readonly R8UI: number;
  75630. readonly RG8UI: number;
  75631. readonly RGB8UI: number;
  75632. readonly RGBA8UI: number;
  75633. readonly R16I: number;
  75634. readonly RG16I: number;
  75635. readonly RGB16I: number;
  75636. readonly RGBA16I: number;
  75637. readonly R16UI: number;
  75638. readonly RG16UI: number;
  75639. readonly RGB16UI: number;
  75640. readonly RGBA16UI: number;
  75641. readonly R32I: number;
  75642. readonly RG32I: number;
  75643. readonly RGB32I: number;
  75644. readonly RGBA32I: number;
  75645. readonly R32UI: number;
  75646. readonly RG32UI: number;
  75647. readonly RGB32UI: number;
  75648. readonly RGBA32UI: number;
  75649. readonly RGB10_A2UI: number;
  75650. readonly R11F_G11F_B10F: number;
  75651. readonly RGB9_E5: number;
  75652. readonly RGB10_A2: number;
  75653. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75654. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75655. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75656. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75657. readonly DEPTH_COMPONENT32F: number;
  75658. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75659. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75660. 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;
  75661. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75662. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75663. readonly TRANSFORM_FEEDBACK: number;
  75664. readonly INTERLEAVED_ATTRIBS: number;
  75665. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75666. createTransformFeedback(): WebGLTransformFeedback;
  75667. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75668. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75669. beginTransformFeedback(primitiveMode: number): void;
  75670. endTransformFeedback(): void;
  75671. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75672. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75673. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75674. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75675. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75676. }
  75677. interface ImageBitmap {
  75678. readonly width: number;
  75679. readonly height: number;
  75680. close(): void;
  75681. }
  75682. interface WebGLQuery extends WebGLObject {
  75683. }
  75684. declare var WebGLQuery: {
  75685. prototype: WebGLQuery;
  75686. new(): WebGLQuery;
  75687. };
  75688. interface WebGLSampler extends WebGLObject {
  75689. }
  75690. declare var WebGLSampler: {
  75691. prototype: WebGLSampler;
  75692. new(): WebGLSampler;
  75693. };
  75694. interface WebGLSync extends WebGLObject {
  75695. }
  75696. declare var WebGLSync: {
  75697. prototype: WebGLSync;
  75698. new(): WebGLSync;
  75699. };
  75700. interface WebGLTransformFeedback extends WebGLObject {
  75701. }
  75702. declare var WebGLTransformFeedback: {
  75703. prototype: WebGLTransformFeedback;
  75704. new(): WebGLTransformFeedback;
  75705. };
  75706. interface WebGLVertexArrayObject extends WebGLObject {
  75707. }
  75708. declare var WebGLVertexArrayObject: {
  75709. prototype: WebGLVertexArrayObject;
  75710. new(): WebGLVertexArrayObject;
  75711. };
  75712. // Type definitions for WebVR API
  75713. // Project: https://w3c.github.io/webvr/
  75714. // Definitions by: six a <https://github.com/lostfictions>
  75715. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75716. interface VRDisplay extends EventTarget {
  75717. /**
  75718. * Dictionary of capabilities describing the VRDisplay.
  75719. */
  75720. readonly capabilities: VRDisplayCapabilities;
  75721. /**
  75722. * z-depth defining the far plane of the eye view frustum
  75723. * enables mapping of values in the render target depth
  75724. * attachment to scene coordinates. Initially set to 10000.0.
  75725. */
  75726. depthFar: number;
  75727. /**
  75728. * z-depth defining the near plane of the eye view frustum
  75729. * enables mapping of values in the render target depth
  75730. * attachment to scene coordinates. Initially set to 0.01.
  75731. */
  75732. depthNear: number;
  75733. /**
  75734. * An identifier for this distinct VRDisplay. Used as an
  75735. * association point in the Gamepad API.
  75736. */
  75737. readonly displayId: number;
  75738. /**
  75739. * A display name, a user-readable name identifying it.
  75740. */
  75741. readonly displayName: string;
  75742. readonly isConnected: boolean;
  75743. readonly isPresenting: boolean;
  75744. /**
  75745. * If this VRDisplay supports room-scale experiences, the optional
  75746. * stage attribute contains details on the room-scale parameters.
  75747. */
  75748. readonly stageParameters: VRStageParameters | null;
  75749. /**
  75750. * Passing the value returned by `requestAnimationFrame` to
  75751. * `cancelAnimationFrame` will unregister the callback.
  75752. * @param handle Define the hanle of the request to cancel
  75753. */
  75754. cancelAnimationFrame(handle: number): void;
  75755. /**
  75756. * Stops presenting to the VRDisplay.
  75757. * @returns a promise to know when it stopped
  75758. */
  75759. exitPresent(): Promise<void>;
  75760. /**
  75761. * Return the current VREyeParameters for the given eye.
  75762. * @param whichEye Define the eye we want the parameter for
  75763. * @returns the eye parameters
  75764. */
  75765. getEyeParameters(whichEye: string): VREyeParameters;
  75766. /**
  75767. * Populates the passed VRFrameData with the information required to render
  75768. * the current frame.
  75769. * @param frameData Define the data structure to populate
  75770. * @returns true if ok otherwise false
  75771. */
  75772. getFrameData(frameData: VRFrameData): boolean;
  75773. /**
  75774. * Get the layers currently being presented.
  75775. * @returns the list of VR layers
  75776. */
  75777. getLayers(): VRLayer[];
  75778. /**
  75779. * Return a VRPose containing the future predicted pose of the VRDisplay
  75780. * when the current frame will be presented. The value returned will not
  75781. * change until JavaScript has returned control to the browser.
  75782. *
  75783. * The VRPose will contain the position, orientation, velocity,
  75784. * and acceleration of each of these properties.
  75785. * @returns the pose object
  75786. */
  75787. getPose(): VRPose;
  75788. /**
  75789. * Return the current instantaneous pose of the VRDisplay, with no
  75790. * prediction applied.
  75791. * @returns the current instantaneous pose
  75792. */
  75793. getImmediatePose(): VRPose;
  75794. /**
  75795. * The callback passed to `requestAnimationFrame` will be called
  75796. * any time a new frame should be rendered. When the VRDisplay is
  75797. * presenting the callback will be called at the native refresh
  75798. * rate of the HMD. When not presenting this function acts
  75799. * identically to how window.requestAnimationFrame acts. Content should
  75800. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75801. * asynchronously from other displays and at differing refresh rates.
  75802. * @param callback Define the eaction to run next frame
  75803. * @returns the request handle it
  75804. */
  75805. requestAnimationFrame(callback: FrameRequestCallback): number;
  75806. /**
  75807. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75808. * Repeat calls while already presenting will update the VRLayers being displayed.
  75809. * @param layers Define the list of layer to present
  75810. * @returns a promise to know when the request has been fulfilled
  75811. */
  75812. requestPresent(layers: VRLayer[]): Promise<void>;
  75813. /**
  75814. * Reset the pose for this display, treating its current position and
  75815. * orientation as the "origin/zero" values. VRPose.position,
  75816. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75817. * updated when calling resetPose(). This should be called in only
  75818. * sitting-space experiences.
  75819. */
  75820. resetPose(): void;
  75821. /**
  75822. * The VRLayer provided to the VRDisplay will be captured and presented
  75823. * in the HMD. Calling this function has the same effect on the source
  75824. * canvas as any other operation that uses its source image, and canvases
  75825. * created without preserveDrawingBuffer set to true will be cleared.
  75826. * @param pose Define the pose to submit
  75827. */
  75828. submitFrame(pose?: VRPose): void;
  75829. }
  75830. declare var VRDisplay: {
  75831. prototype: VRDisplay;
  75832. new(): VRDisplay;
  75833. };
  75834. interface VRLayer {
  75835. leftBounds?: number[] | Float32Array | null;
  75836. rightBounds?: number[] | Float32Array | null;
  75837. source?: HTMLCanvasElement | null;
  75838. }
  75839. interface VRDisplayCapabilities {
  75840. readonly canPresent: boolean;
  75841. readonly hasExternalDisplay: boolean;
  75842. readonly hasOrientation: boolean;
  75843. readonly hasPosition: boolean;
  75844. readonly maxLayers: number;
  75845. }
  75846. interface VREyeParameters {
  75847. /** @deprecated */
  75848. readonly fieldOfView: VRFieldOfView;
  75849. readonly offset: Float32Array;
  75850. readonly renderHeight: number;
  75851. readonly renderWidth: number;
  75852. }
  75853. interface VRFieldOfView {
  75854. readonly downDegrees: number;
  75855. readonly leftDegrees: number;
  75856. readonly rightDegrees: number;
  75857. readonly upDegrees: number;
  75858. }
  75859. interface VRFrameData {
  75860. readonly leftProjectionMatrix: Float32Array;
  75861. readonly leftViewMatrix: Float32Array;
  75862. readonly pose: VRPose;
  75863. readonly rightProjectionMatrix: Float32Array;
  75864. readonly rightViewMatrix: Float32Array;
  75865. readonly timestamp: number;
  75866. }
  75867. interface VRPose {
  75868. readonly angularAcceleration: Float32Array | null;
  75869. readonly angularVelocity: Float32Array | null;
  75870. readonly linearAcceleration: Float32Array | null;
  75871. readonly linearVelocity: Float32Array | null;
  75872. readonly orientation: Float32Array | null;
  75873. readonly position: Float32Array | null;
  75874. readonly timestamp: number;
  75875. }
  75876. interface VRStageParameters {
  75877. sittingToStandingTransform?: Float32Array;
  75878. sizeX?: number;
  75879. sizeY?: number;
  75880. }
  75881. interface Navigator {
  75882. getVRDisplays(): Promise<VRDisplay[]>;
  75883. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75884. }
  75885. interface Window {
  75886. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75887. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75888. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75889. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75890. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75891. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75892. }
  75893. interface Gamepad {
  75894. readonly displayId: number;
  75895. }
  75896. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75897. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75898. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75899. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75900. type XRHandedness = "none" | "left" | "right";
  75901. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75902. type XREye = "none" | "left" | "right";
  75903. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75904. interface XRSpace extends EventTarget {}
  75905. interface XRRenderState {
  75906. depthNear?: number;
  75907. depthFar?: number;
  75908. inlineVerticalFieldOfView?: number;
  75909. baseLayer?: XRWebGLLayer;
  75910. }
  75911. interface XRInputSource {
  75912. handedness: XRHandedness;
  75913. targetRayMode: XRTargetRayMode;
  75914. targetRaySpace: XRSpace;
  75915. gripSpace: XRSpace | undefined;
  75916. gamepad: Gamepad | undefined;
  75917. profiles: Array<string>;
  75918. hand: XRHand | undefined;
  75919. }
  75920. interface XRSessionInit {
  75921. optionalFeatures?: string[];
  75922. requiredFeatures?: string[];
  75923. }
  75924. interface XRSession {
  75925. addEventListener: Function;
  75926. removeEventListener: Function;
  75927. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75928. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75929. requestAnimationFrame: Function;
  75930. end(): Promise<void>;
  75931. renderState: XRRenderState;
  75932. inputSources: Array<XRInputSource>;
  75933. // hit test
  75934. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75935. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75936. // legacy AR hit test
  75937. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75938. // legacy plane detection
  75939. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  75940. }
  75941. interface XRReferenceSpace extends XRSpace {
  75942. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75943. onreset: any;
  75944. }
  75945. type XRPlaneSet = Set<XRPlane>;
  75946. type XRAnchorSet = Set<XRAnchor>;
  75947. interface XRFrame {
  75948. session: XRSession;
  75949. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75950. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75951. // AR
  75952. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  75953. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75954. // Anchors
  75955. trackedAnchors?: XRAnchorSet;
  75956. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75957. // Planes
  75958. worldInformation: {
  75959. detectedPlanes?: XRPlaneSet;
  75960. };
  75961. // Hand tracking
  75962. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  75963. }
  75964. interface XRViewerPose extends XRPose {
  75965. views: Array<XRView>;
  75966. }
  75967. interface XRPose {
  75968. transform: XRRigidTransform;
  75969. emulatedPosition: boolean;
  75970. }
  75971. interface XRWebGLLayerOptions {
  75972. antialias?: boolean;
  75973. depth?: boolean;
  75974. stencil?: boolean;
  75975. alpha?: boolean;
  75976. multiview?: boolean;
  75977. framebufferScaleFactor?: number;
  75978. }
  75979. declare var XRWebGLLayer: {
  75980. prototype: XRWebGLLayer;
  75981. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75982. };
  75983. interface XRWebGLLayer {
  75984. framebuffer: WebGLFramebuffer;
  75985. framebufferWidth: number;
  75986. framebufferHeight: number;
  75987. getViewport: Function;
  75988. }
  75989. declare class XRRigidTransform {
  75990. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75991. position: DOMPointReadOnly;
  75992. orientation: DOMPointReadOnly;
  75993. matrix: Float32Array;
  75994. inverse: XRRigidTransform;
  75995. }
  75996. interface XRView {
  75997. eye: XREye;
  75998. projectionMatrix: Float32Array;
  75999. transform: XRRigidTransform;
  76000. }
  76001. interface XRInputSourceChangeEvent {
  76002. session: XRSession;
  76003. removed: Array<XRInputSource>;
  76004. added: Array<XRInputSource>;
  76005. }
  76006. interface XRInputSourceEvent extends Event {
  76007. readonly frame: XRFrame;
  76008. readonly inputSource: XRInputSource;
  76009. }
  76010. // Experimental(er) features
  76011. declare class XRRay {
  76012. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76013. origin: DOMPointReadOnly;
  76014. direction: DOMPointReadOnly;
  76015. matrix: Float32Array;
  76016. }
  76017. declare enum XRHitTestTrackableType {
  76018. "point",
  76019. "plane",
  76020. "mesh",
  76021. }
  76022. interface XRHitResult {
  76023. hitMatrix: Float32Array;
  76024. }
  76025. interface XRTransientInputHitTestResult {
  76026. readonly inputSource: XRInputSource;
  76027. readonly results: Array<XRHitTestResult>;
  76028. }
  76029. interface XRHitTestResult {
  76030. getPose(baseSpace: XRSpace): XRPose | undefined;
  76031. // When anchor system is enabled
  76032. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76033. }
  76034. interface XRHitTestSource {
  76035. cancel(): void;
  76036. }
  76037. interface XRTransientInputHitTestSource {
  76038. cancel(): void;
  76039. }
  76040. interface XRHitTestOptionsInit {
  76041. space: XRSpace;
  76042. entityTypes?: Array<XRHitTestTrackableType>;
  76043. offsetRay?: XRRay;
  76044. }
  76045. interface XRTransientInputHitTestOptionsInit {
  76046. profile: string;
  76047. entityTypes?: Array<XRHitTestTrackableType>;
  76048. offsetRay?: XRRay;
  76049. }
  76050. interface XRAnchor {
  76051. anchorSpace: XRSpace;
  76052. delete(): void;
  76053. }
  76054. interface XRPlane {
  76055. orientation: "Horizontal" | "Vertical";
  76056. planeSpace: XRSpace;
  76057. polygon: Array<DOMPointReadOnly>;
  76058. lastChangedTime: number;
  76059. }
  76060. interface XRJointSpace extends XRSpace {}
  76061. interface XRJointPose extends XRPose {
  76062. radius: number | undefined;
  76063. }
  76064. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76065. readonly length: number;
  76066. [index: number]: XRJointSpace;
  76067. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76068. readonly WRIST: number;
  76069. readonly THUMB_METACARPAL: number;
  76070. readonly THUMB_PHALANX_PROXIMAL: number;
  76071. readonly THUMB_PHALANX_DISTAL: number;
  76072. readonly THUMB_PHALANX_TIP: number;
  76073. readonly INDEX_METACARPAL: number;
  76074. readonly INDEX_PHALANX_PROXIMAL: number;
  76075. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76076. readonly INDEX_PHALANX_DISTAL: number;
  76077. readonly INDEX_PHALANX_TIP: number;
  76078. readonly MIDDLE_METACARPAL: number;
  76079. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76080. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76081. readonly MIDDLE_PHALANX_DISTAL: number;
  76082. readonly MIDDLE_PHALANX_TIP: number;
  76083. readonly RING_METACARPAL: number;
  76084. readonly RING_PHALANX_PROXIMAL: number;
  76085. readonly RING_PHALANX_INTERMEDIATE: number;
  76086. readonly RING_PHALANX_DISTAL: number;
  76087. readonly RING_PHALANX_TIP: number;
  76088. readonly LITTLE_METACARPAL: number;
  76089. readonly LITTLE_PHALANX_PROXIMAL: number;
  76090. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76091. readonly LITTLE_PHALANX_DISTAL: number;
  76092. readonly LITTLE_PHALANX_TIP: number;
  76093. }
  76094. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76095. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76096. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76097. interface XRSession {
  76098. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76099. }
  76100. interface XRFrame {
  76101. featurePointCloud? : Array<number>;
  76102. }
  76103. /**
  76104. * @ignore
  76105. */
  76106. declare module BABYLON.GLTF2.Exporter {
  76107. }
  76108. /**
  76109. * @ignore
  76110. */
  76111. declare module BABYLON.GLTF1 {
  76112. }
  76113. declare module BABYLON.GUI {
  76114. /**
  76115. * Class used to specific a value and its associated unit
  76116. */
  76117. export class ValueAndUnit {
  76118. /** defines the unit to store */
  76119. unit: number;
  76120. /** defines a boolean indicating if the value can be negative */
  76121. negativeValueAllowed: boolean;
  76122. private _value;
  76123. private _originalUnit;
  76124. /**
  76125. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76126. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76127. */
  76128. ignoreAdaptiveScaling: boolean;
  76129. /**
  76130. * Creates a new ValueAndUnit
  76131. * @param value defines the value to store
  76132. * @param unit defines the unit to store
  76133. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76134. */
  76135. constructor(value: number,
  76136. /** defines the unit to store */
  76137. unit?: number,
  76138. /** defines a boolean indicating if the value can be negative */
  76139. negativeValueAllowed?: boolean);
  76140. /** Gets a boolean indicating if the value is a percentage */
  76141. get isPercentage(): boolean;
  76142. /** Gets a boolean indicating if the value is store as pixel */
  76143. get isPixel(): boolean;
  76144. /** Gets direct internal value */
  76145. get internalValue(): number;
  76146. /**
  76147. * Gets value as pixel
  76148. * @param host defines the root host
  76149. * @param refValue defines the reference value for percentages
  76150. * @returns the value as pixel
  76151. */
  76152. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76153. /**
  76154. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76155. * @param value defines the value to store
  76156. * @param unit defines the unit to store
  76157. * @returns the current ValueAndUnit
  76158. */
  76159. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76160. /**
  76161. * Gets the value accordingly to its unit
  76162. * @param host defines the root host
  76163. * @returns the value
  76164. */
  76165. getValue(host: AdvancedDynamicTexture): number;
  76166. /**
  76167. * Gets a string representation of the value
  76168. * @param host defines the root host
  76169. * @param decimals defines an optional number of decimals to display
  76170. * @returns a string
  76171. */
  76172. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76173. /**
  76174. * Store a value parsed from a string
  76175. * @param source defines the source string
  76176. * @returns true if the value was successfully parsed
  76177. */
  76178. fromString(source: string | number): boolean;
  76179. private static _Regex;
  76180. private static _UNITMODE_PERCENTAGE;
  76181. private static _UNITMODE_PIXEL;
  76182. /** UNITMODE_PERCENTAGE */
  76183. static get UNITMODE_PERCENTAGE(): number;
  76184. /** UNITMODE_PIXEL */
  76185. static get UNITMODE_PIXEL(): number;
  76186. }
  76187. }
  76188. declare module BABYLON.GUI {
  76189. /**
  76190. * Define a style used by control to automatically setup properties based on a template.
  76191. * Only support font related properties so far
  76192. */
  76193. export class Style implements BABYLON.IDisposable {
  76194. private _fontFamily;
  76195. private _fontStyle;
  76196. private _fontWeight;
  76197. /** @hidden */
  76198. _host: AdvancedDynamicTexture;
  76199. /** @hidden */
  76200. _fontSize: ValueAndUnit;
  76201. /**
  76202. * BABYLON.Observable raised when the style values are changed
  76203. */
  76204. onChangedObservable: BABYLON.Observable<Style>;
  76205. /**
  76206. * Creates a new style object
  76207. * @param host defines the AdvancedDynamicTexture which hosts this style
  76208. */
  76209. constructor(host: AdvancedDynamicTexture);
  76210. /**
  76211. * Gets or sets the font size
  76212. */
  76213. get fontSize(): string | number;
  76214. set fontSize(value: string | number);
  76215. /**
  76216. * Gets or sets the font family
  76217. */
  76218. get fontFamily(): string;
  76219. set fontFamily(value: string);
  76220. /**
  76221. * Gets or sets the font style
  76222. */
  76223. get fontStyle(): string;
  76224. set fontStyle(value: string);
  76225. /** Gets or sets font weight */
  76226. get fontWeight(): string;
  76227. set fontWeight(value: string);
  76228. /** Dispose all associated resources */
  76229. dispose(): void;
  76230. }
  76231. }
  76232. declare module BABYLON.GUI {
  76233. /**
  76234. * Class used to transport BABYLON.Vector2 information for pointer events
  76235. */
  76236. export class Vector2WithInfo extends BABYLON.Vector2 {
  76237. /** defines the current mouse button index */
  76238. buttonIndex: number;
  76239. /**
  76240. * Creates a new Vector2WithInfo
  76241. * @param source defines the vector2 data to transport
  76242. * @param buttonIndex defines the current mouse button index
  76243. */
  76244. constructor(source: BABYLON.Vector2,
  76245. /** defines the current mouse button index */
  76246. buttonIndex?: number);
  76247. }
  76248. /** Class used to provide 2D matrix features */
  76249. export class Matrix2D {
  76250. /** Gets the internal array of 6 floats used to store matrix data */
  76251. m: Float32Array;
  76252. /**
  76253. * Creates a new matrix
  76254. * @param m00 defines value for (0, 0)
  76255. * @param m01 defines value for (0, 1)
  76256. * @param m10 defines value for (1, 0)
  76257. * @param m11 defines value for (1, 1)
  76258. * @param m20 defines value for (2, 0)
  76259. * @param m21 defines value for (2, 1)
  76260. */
  76261. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76262. /**
  76263. * Fills the matrix from direct values
  76264. * @param m00 defines value for (0, 0)
  76265. * @param m01 defines value for (0, 1)
  76266. * @param m10 defines value for (1, 0)
  76267. * @param m11 defines value for (1, 1)
  76268. * @param m20 defines value for (2, 0)
  76269. * @param m21 defines value for (2, 1)
  76270. * @returns the current modified matrix
  76271. */
  76272. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76273. /**
  76274. * Gets matrix determinant
  76275. * @returns the determinant
  76276. */
  76277. determinant(): number;
  76278. /**
  76279. * Inverses the matrix and stores it in a target matrix
  76280. * @param result defines the target matrix
  76281. * @returns the current matrix
  76282. */
  76283. invertToRef(result: Matrix2D): Matrix2D;
  76284. /**
  76285. * Multiplies the current matrix with another one
  76286. * @param other defines the second operand
  76287. * @param result defines the target matrix
  76288. * @returns the current matrix
  76289. */
  76290. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76291. /**
  76292. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76293. * @param x defines the x coordinate to transform
  76294. * @param y defines the x coordinate to transform
  76295. * @param result defines the target vector2
  76296. * @returns the current matrix
  76297. */
  76298. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76299. /**
  76300. * Creates an identity matrix
  76301. * @returns a new matrix
  76302. */
  76303. static Identity(): Matrix2D;
  76304. /**
  76305. * Creates a translation matrix and stores it in a target matrix
  76306. * @param x defines the x coordinate of the translation
  76307. * @param y defines the y coordinate of the translation
  76308. * @param result defines the target matrix
  76309. */
  76310. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76311. /**
  76312. * Creates a scaling matrix and stores it in a target matrix
  76313. * @param x defines the x coordinate of the scaling
  76314. * @param y defines the y coordinate of the scaling
  76315. * @param result defines the target matrix
  76316. */
  76317. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76318. /**
  76319. * Creates a rotation matrix and stores it in a target matrix
  76320. * @param angle defines the rotation angle
  76321. * @param result defines the target matrix
  76322. */
  76323. static RotationToRef(angle: number, result: Matrix2D): void;
  76324. private static _TempPreTranslationMatrix;
  76325. private static _TempPostTranslationMatrix;
  76326. private static _TempRotationMatrix;
  76327. private static _TempScalingMatrix;
  76328. private static _TempCompose0;
  76329. private static _TempCompose1;
  76330. private static _TempCompose2;
  76331. /**
  76332. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76333. * @param tx defines the x coordinate of the translation
  76334. * @param ty defines the y coordinate of the translation
  76335. * @param angle defines the rotation angle
  76336. * @param scaleX defines the x coordinate of the scaling
  76337. * @param scaleY defines the y coordinate of the scaling
  76338. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76339. * @param result defines the target matrix
  76340. */
  76341. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76342. }
  76343. }
  76344. declare module BABYLON.GUI {
  76345. /**
  76346. * Class used to store 2D control sizes
  76347. */
  76348. export class Measure {
  76349. /** defines left coordinate */
  76350. left: number;
  76351. /** defines top coordinate */
  76352. top: number;
  76353. /** defines width dimension */
  76354. width: number;
  76355. /** defines height dimension */
  76356. height: number;
  76357. /**
  76358. * Creates a new measure
  76359. * @param left defines left coordinate
  76360. * @param top defines top coordinate
  76361. * @param width defines width dimension
  76362. * @param height defines height dimension
  76363. */
  76364. constructor(
  76365. /** defines left coordinate */
  76366. left: number,
  76367. /** defines top coordinate */
  76368. top: number,
  76369. /** defines width dimension */
  76370. width: number,
  76371. /** defines height dimension */
  76372. height: number);
  76373. /**
  76374. * Copy from another measure
  76375. * @param other defines the other measure to copy from
  76376. */
  76377. copyFrom(other: Measure): void;
  76378. /**
  76379. * Copy from a group of 4 floats
  76380. * @param left defines left coordinate
  76381. * @param top defines top coordinate
  76382. * @param width defines width dimension
  76383. * @param height defines height dimension
  76384. */
  76385. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76386. /**
  76387. * Computes the axis aligned bounding box measure for two given measures
  76388. * @param a Input measure
  76389. * @param b Input measure
  76390. * @param result the resulting bounding measure
  76391. */
  76392. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76393. /**
  76394. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76395. * @param transform the matrix to transform the measure before computing the AABB
  76396. * @param addX number to add to left
  76397. * @param addY number to add to top
  76398. * @param addWidth number to add to width
  76399. * @param addHeight number to add to height
  76400. * @param result the resulting AABB
  76401. */
  76402. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76403. /**
  76404. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76405. * @param transform the matrix to transform the measure before computing the AABB
  76406. * @param result the resulting AABB
  76407. */
  76408. transformToRef(transform: Matrix2D, result: Measure): void;
  76409. /**
  76410. * Check equality between this measure and another one
  76411. * @param other defines the other measures
  76412. * @returns true if both measures are equals
  76413. */
  76414. isEqualsTo(other: Measure): boolean;
  76415. /**
  76416. * Creates an empty measure
  76417. * @returns a new measure
  76418. */
  76419. static Empty(): Measure;
  76420. }
  76421. }
  76422. declare module BABYLON.GUI {
  76423. /**
  76424. * Interface used to define a control that can receive focus
  76425. */
  76426. export interface IFocusableControl {
  76427. /**
  76428. * Function called when the control receives the focus
  76429. */
  76430. onFocus(): void;
  76431. /**
  76432. * Function called when the control loses the focus
  76433. */
  76434. onBlur(): void;
  76435. /**
  76436. * Function called to let the control handle keyboard events
  76437. * @param evt defines the current keyboard event
  76438. */
  76439. processKeyboard(evt: KeyboardEvent): void;
  76440. /**
  76441. * Function called to get the list of controls that should not steal the focus from this control
  76442. * @returns an array of controls
  76443. */
  76444. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76445. }
  76446. /**
  76447. * Class used to create texture to support 2D GUI elements
  76448. * @see https://doc.babylonjs.com/how_to/gui
  76449. */
  76450. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76451. private _isDirty;
  76452. private _renderObserver;
  76453. private _resizeObserver;
  76454. private _preKeyboardObserver;
  76455. private _pointerMoveObserver;
  76456. private _pointerObserver;
  76457. private _canvasPointerOutObserver;
  76458. private _canvasBlurObserver;
  76459. private _background;
  76460. /** @hidden */
  76461. _rootContainer: Container;
  76462. /** @hidden */
  76463. _lastPickedControl: Control;
  76464. /** @hidden */
  76465. _lastControlOver: {
  76466. [pointerId: number]: Control;
  76467. };
  76468. /** @hidden */
  76469. _lastControlDown: {
  76470. [pointerId: number]: Control;
  76471. };
  76472. /** @hidden */
  76473. _capturingControl: {
  76474. [pointerId: number]: Control;
  76475. };
  76476. /** @hidden */
  76477. _shouldBlockPointer: boolean;
  76478. /** @hidden */
  76479. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76480. /** @hidden */
  76481. _linkedControls: Control[];
  76482. private _isFullscreen;
  76483. private _fullscreenViewport;
  76484. private _idealWidth;
  76485. private _idealHeight;
  76486. private _useSmallestIdeal;
  76487. private _renderAtIdealSize;
  76488. private _focusedControl;
  76489. private _blockNextFocusCheck;
  76490. private _renderScale;
  76491. private _rootElement;
  76492. private _cursorChanged;
  76493. private _defaultMousePointerId;
  76494. /** @hidden */
  76495. _numLayoutCalls: number;
  76496. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76497. get numLayoutCalls(): number;
  76498. /** @hidden */
  76499. _numRenderCalls: number;
  76500. /** Gets the number of render calls made the last time the ADT has been rendered */
  76501. get numRenderCalls(): number;
  76502. /**
  76503. * Define type to string to ensure compatibility across browsers
  76504. * Safari doesn't support DataTransfer constructor
  76505. */
  76506. private _clipboardData;
  76507. /**
  76508. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76509. */
  76510. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76511. /**
  76512. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76513. */
  76514. onControlPickedObservable: BABYLON.Observable<Control>;
  76515. /**
  76516. * BABYLON.Observable event triggered before layout is evaluated
  76517. */
  76518. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76519. /**
  76520. * BABYLON.Observable event triggered after the layout was evaluated
  76521. */
  76522. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76523. /**
  76524. * BABYLON.Observable event triggered before the texture is rendered
  76525. */
  76526. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76527. /**
  76528. * BABYLON.Observable event triggered after the texture was rendered
  76529. */
  76530. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76531. /**
  76532. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76533. */
  76534. premulAlpha: boolean;
  76535. /**
  76536. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76537. * Useful when you want more antialiasing
  76538. */
  76539. get renderScale(): number;
  76540. set renderScale(value: number);
  76541. /** Gets or sets the background color */
  76542. get background(): string;
  76543. set background(value: string);
  76544. /**
  76545. * Gets or sets the ideal width used to design controls.
  76546. * The GUI will then rescale everything accordingly
  76547. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76548. */
  76549. get idealWidth(): number;
  76550. set idealWidth(value: number);
  76551. /**
  76552. * Gets or sets the ideal height used to design controls.
  76553. * The GUI will then rescale everything accordingly
  76554. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76555. */
  76556. get idealHeight(): number;
  76557. set idealHeight(value: number);
  76558. /**
  76559. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76560. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76561. */
  76562. get useSmallestIdeal(): boolean;
  76563. set useSmallestIdeal(value: boolean);
  76564. /**
  76565. * Gets or sets a boolean indicating if adaptive scaling must be used
  76566. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76567. */
  76568. get renderAtIdealSize(): boolean;
  76569. set renderAtIdealSize(value: boolean);
  76570. /**
  76571. * Gets the ratio used when in "ideal mode"
  76572. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76573. * */
  76574. get idealRatio(): number;
  76575. /**
  76576. * Gets the underlying layer used to render the texture when in fullscreen mode
  76577. */
  76578. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76579. /**
  76580. * Gets the root container control
  76581. */
  76582. get rootContainer(): Container;
  76583. /**
  76584. * Returns an array containing the root container.
  76585. * This is mostly used to let the Inspector introspects the ADT
  76586. * @returns an array containing the rootContainer
  76587. */
  76588. getChildren(): Array<Container>;
  76589. /**
  76590. * Will return all controls that are inside this texture
  76591. * @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
  76592. * @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
  76593. * @return all child controls
  76594. */
  76595. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76596. /**
  76597. * Gets or sets the current focused control
  76598. */
  76599. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76600. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76601. /**
  76602. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76603. */
  76604. get isForeground(): boolean;
  76605. set isForeground(value: boolean);
  76606. /**
  76607. * Gets or set information about clipboardData
  76608. */
  76609. get clipboardData(): string;
  76610. set clipboardData(value: string);
  76611. /**
  76612. * Creates a new AdvancedDynamicTexture
  76613. * @param name defines the name of the texture
  76614. * @param width defines the width of the texture
  76615. * @param height defines the height of the texture
  76616. * @param scene defines the hosting scene
  76617. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76618. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76619. */
  76620. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76621. /**
  76622. * Get the current class name of the texture useful for serialization or dynamic coding.
  76623. * @returns "AdvancedDynamicTexture"
  76624. */
  76625. getClassName(): string;
  76626. /**
  76627. * Function used to execute a function on all controls
  76628. * @param func defines the function to execute
  76629. * @param container defines the container where controls belong. If null the root container will be used
  76630. */
  76631. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76632. private _useInvalidateRectOptimization;
  76633. /**
  76634. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76635. */
  76636. get useInvalidateRectOptimization(): boolean;
  76637. set useInvalidateRectOptimization(value: boolean);
  76638. private _invalidatedRectangle;
  76639. /**
  76640. * Invalidates a rectangle area on the gui texture
  76641. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76642. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76643. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76644. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76645. */
  76646. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76647. /**
  76648. * Marks the texture as dirty forcing a complete update
  76649. */
  76650. markAsDirty(): void;
  76651. /**
  76652. * Helper function used to create a new style
  76653. * @returns a new style
  76654. * @see https://doc.babylonjs.com/how_to/gui#styles
  76655. */
  76656. createStyle(): Style;
  76657. /**
  76658. * Adds a new control to the root container
  76659. * @param control defines the control to add
  76660. * @returns the current texture
  76661. */
  76662. addControl(control: Control): AdvancedDynamicTexture;
  76663. /**
  76664. * Removes a control from the root container
  76665. * @param control defines the control to remove
  76666. * @returns the current texture
  76667. */
  76668. removeControl(control: Control): AdvancedDynamicTexture;
  76669. /**
  76670. * Release all resources
  76671. */
  76672. dispose(): void;
  76673. private _onResize;
  76674. /** @hidden */
  76675. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76676. /**
  76677. * Get screen coordinates for a vector3
  76678. * @param position defines the position to project
  76679. * @param worldMatrix defines the world matrix to use
  76680. * @returns the projected position
  76681. */
  76682. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76683. private _checkUpdate;
  76684. private _clearMeasure;
  76685. private _render;
  76686. /** @hidden */
  76687. _changeCursor(cursor: string): void;
  76688. /** @hidden */
  76689. _registerLastControlDown(control: Control, pointerId: number): void;
  76690. private _doPicking;
  76691. /** @hidden */
  76692. _cleanControlAfterRemovalFromList(list: {
  76693. [pointerId: number]: Control;
  76694. }, control: Control): void;
  76695. /** @hidden */
  76696. _cleanControlAfterRemoval(control: Control): void;
  76697. /** Attach to all scene events required to support pointer events */
  76698. attach(): void;
  76699. /** @hidden */
  76700. private onClipboardCopy;
  76701. /** @hidden */
  76702. private onClipboardCut;
  76703. /** @hidden */
  76704. private onClipboardPaste;
  76705. /**
  76706. * Register the clipboard Events onto the canvas
  76707. */
  76708. registerClipboardEvents(): void;
  76709. /**
  76710. * Unregister the clipboard Events from the canvas
  76711. */
  76712. unRegisterClipboardEvents(): void;
  76713. /**
  76714. * Connect the texture to a hosting mesh to enable interactions
  76715. * @param mesh defines the mesh to attach to
  76716. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76717. */
  76718. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76719. /**
  76720. * Move the focus to a specific control
  76721. * @param control defines the control which will receive the focus
  76722. */
  76723. moveFocusToControl(control: IFocusableControl): void;
  76724. private _manageFocus;
  76725. private _attachToOnPointerOut;
  76726. private _attachToOnBlur;
  76727. /**
  76728. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76729. * @param mesh defines the mesh which will receive the texture
  76730. * @param width defines the texture width (1024 by default)
  76731. * @param height defines the texture height (1024 by default)
  76732. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76733. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76734. * @returns a new AdvancedDynamicTexture
  76735. */
  76736. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76737. /**
  76738. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76739. * In this mode the texture will rely on a layer for its rendering.
  76740. * This allows it to be treated like any other layer.
  76741. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76742. * LayerMask is set through advancedTexture.layer.layerMask
  76743. * @param name defines name for the texture
  76744. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76745. * @param scene defines the hsoting scene
  76746. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76747. * @returns a new AdvancedDynamicTexture
  76748. */
  76749. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76750. }
  76751. }
  76752. declare module BABYLON.GUI {
  76753. /**
  76754. * Root class used for all 2D controls
  76755. * @see https://doc.babylonjs.com/how_to/gui#controls
  76756. */
  76757. export class Control {
  76758. /** defines the name of the control */
  76759. name?: string | undefined;
  76760. /**
  76761. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76762. */
  76763. static AllowAlphaInheritance: boolean;
  76764. private _alpha;
  76765. private _alphaSet;
  76766. private _zIndex;
  76767. /** @hidden */
  76768. _host: AdvancedDynamicTexture;
  76769. /** Gets or sets the control parent */
  76770. parent: BABYLON.Nullable<Container>;
  76771. /** @hidden */
  76772. _currentMeasure: Measure;
  76773. private _fontFamily;
  76774. private _fontStyle;
  76775. private _fontWeight;
  76776. private _fontSize;
  76777. private _font;
  76778. /** @hidden */
  76779. _width: ValueAndUnit;
  76780. /** @hidden */
  76781. _height: ValueAndUnit;
  76782. /** @hidden */
  76783. protected _fontOffset: {
  76784. ascent: number;
  76785. height: number;
  76786. descent: number;
  76787. };
  76788. private _color;
  76789. private _style;
  76790. private _styleObserver;
  76791. /** @hidden */
  76792. protected _horizontalAlignment: number;
  76793. /** @hidden */
  76794. protected _verticalAlignment: number;
  76795. /** @hidden */
  76796. protected _isDirty: boolean;
  76797. /** @hidden */
  76798. protected _wasDirty: boolean;
  76799. /** @hidden */
  76800. _tempParentMeasure: Measure;
  76801. /** @hidden */
  76802. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76803. /** @hidden */
  76804. protected _cachedParentMeasure: Measure;
  76805. private _paddingLeft;
  76806. private _paddingRight;
  76807. private _paddingTop;
  76808. private _paddingBottom;
  76809. /** @hidden */
  76810. _left: ValueAndUnit;
  76811. /** @hidden */
  76812. _top: ValueAndUnit;
  76813. private _scaleX;
  76814. private _scaleY;
  76815. private _rotation;
  76816. private _transformCenterX;
  76817. private _transformCenterY;
  76818. /** @hidden */
  76819. _transformMatrix: Matrix2D;
  76820. /** @hidden */
  76821. protected _invertTransformMatrix: Matrix2D;
  76822. /** @hidden */
  76823. protected _transformedPosition: BABYLON.Vector2;
  76824. private _isMatrixDirty;
  76825. private _cachedOffsetX;
  76826. private _cachedOffsetY;
  76827. private _isVisible;
  76828. private _isHighlighted;
  76829. /** @hidden */
  76830. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76831. private _fontSet;
  76832. private _dummyVector2;
  76833. private _downCount;
  76834. private _enterCount;
  76835. private _doNotRender;
  76836. private _downPointerIds;
  76837. protected _isEnabled: boolean;
  76838. protected _disabledColor: string;
  76839. protected _disabledColorItem: string;
  76840. /** @hidden */
  76841. protected _rebuildLayout: boolean;
  76842. /** @hidden */
  76843. _customData: any;
  76844. /** @hidden */
  76845. _isClipped: boolean;
  76846. /** @hidden */
  76847. _automaticSize: boolean;
  76848. /** @hidden */
  76849. _tag: any;
  76850. /**
  76851. * 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
  76852. */
  76853. uniqueId: number;
  76854. /**
  76855. * Gets or sets an object used to store user defined information for the node
  76856. */
  76857. metadata: any;
  76858. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76859. isHitTestVisible: boolean;
  76860. /** Gets or sets a boolean indicating if the control can block pointer events */
  76861. isPointerBlocker: boolean;
  76862. /** Gets or sets a boolean indicating if the control can be focusable */
  76863. isFocusInvisible: boolean;
  76864. /**
  76865. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76866. * 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
  76867. */
  76868. clipChildren: boolean;
  76869. /**
  76870. * Gets or sets a boolean indicating that control content must be clipped
  76871. * 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
  76872. */
  76873. clipContent: boolean;
  76874. /**
  76875. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76876. */
  76877. useBitmapCache: boolean;
  76878. private _cacheData;
  76879. private _shadowOffsetX;
  76880. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76881. get shadowOffsetX(): number;
  76882. set shadowOffsetX(value: number);
  76883. private _shadowOffsetY;
  76884. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76885. get shadowOffsetY(): number;
  76886. set shadowOffsetY(value: number);
  76887. private _shadowBlur;
  76888. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76889. get shadowBlur(): number;
  76890. set shadowBlur(value: number);
  76891. private _shadowColor;
  76892. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76893. get shadowColor(): string;
  76894. set shadowColor(value: string);
  76895. /** Gets or sets the cursor to use when the control is hovered */
  76896. hoverCursor: string;
  76897. /** @hidden */
  76898. protected _linkOffsetX: ValueAndUnit;
  76899. /** @hidden */
  76900. protected _linkOffsetY: ValueAndUnit;
  76901. /** Gets the control type name */
  76902. get typeName(): string;
  76903. /**
  76904. * Get the current class name of the control.
  76905. * @returns current class name
  76906. */
  76907. getClassName(): string;
  76908. /**
  76909. * An event triggered when pointer wheel is scrolled
  76910. */
  76911. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76912. /**
  76913. * An event triggered when the pointer move over the control.
  76914. */
  76915. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76916. /**
  76917. * An event triggered when the pointer move out of the control.
  76918. */
  76919. onPointerOutObservable: BABYLON.Observable<Control>;
  76920. /**
  76921. * An event triggered when the pointer taps the control
  76922. */
  76923. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76924. /**
  76925. * An event triggered when pointer up
  76926. */
  76927. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76928. /**
  76929. * An event triggered when a control is clicked on
  76930. */
  76931. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76932. /**
  76933. * An event triggered when pointer enters the control
  76934. */
  76935. onPointerEnterObservable: BABYLON.Observable<Control>;
  76936. /**
  76937. * An event triggered when the control is marked as dirty
  76938. */
  76939. onDirtyObservable: BABYLON.Observable<Control>;
  76940. /**
  76941. * An event triggered before drawing the control
  76942. */
  76943. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76944. /**
  76945. * An event triggered after the control was drawn
  76946. */
  76947. onAfterDrawObservable: BABYLON.Observable<Control>;
  76948. /**
  76949. * An event triggered when the control has been disposed
  76950. */
  76951. onDisposeObservable: BABYLON.Observable<Control>;
  76952. /**
  76953. * Get the hosting AdvancedDynamicTexture
  76954. */
  76955. get host(): AdvancedDynamicTexture;
  76956. /** Gets or set information about font offsets (used to render and align text) */
  76957. get fontOffset(): {
  76958. ascent: number;
  76959. height: number;
  76960. descent: number;
  76961. };
  76962. set fontOffset(offset: {
  76963. ascent: number;
  76964. height: number;
  76965. descent: number;
  76966. });
  76967. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76968. get alpha(): number;
  76969. set alpha(value: number);
  76970. /**
  76971. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76972. */
  76973. get isHighlighted(): boolean;
  76974. set isHighlighted(value: boolean);
  76975. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76976. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76977. */
  76978. get scaleX(): number;
  76979. set scaleX(value: number);
  76980. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76981. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76982. */
  76983. get scaleY(): number;
  76984. set scaleY(value: number);
  76985. /** Gets or sets the rotation angle (0 by default)
  76986. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76987. */
  76988. get rotation(): number;
  76989. set rotation(value: number);
  76990. /** Gets or sets the transformation center on Y axis (0 by default)
  76991. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76992. */
  76993. get transformCenterY(): number;
  76994. set transformCenterY(value: number);
  76995. /** Gets or sets the transformation center on X axis (0 by default)
  76996. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76997. */
  76998. get transformCenterX(): number;
  76999. set transformCenterX(value: number);
  77000. /**
  77001. * Gets or sets the horizontal alignment
  77002. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77003. */
  77004. get horizontalAlignment(): number;
  77005. set horizontalAlignment(value: number);
  77006. /**
  77007. * Gets or sets the vertical alignment
  77008. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77009. */
  77010. get verticalAlignment(): number;
  77011. set verticalAlignment(value: number);
  77012. /**
  77013. * Gets or sets a fixed ratio for this control.
  77014. * When different from 0, the ratio is used to compute the "second" dimension.
  77015. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77016. * second dimension is computed as first dimension * fixedRatio
  77017. */
  77018. fixedRatio: number;
  77019. private _fixedRatioMasterIsWidth;
  77020. /**
  77021. * Gets or sets control width
  77022. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77023. */
  77024. get width(): string | number;
  77025. set width(value: string | number);
  77026. /**
  77027. * Gets or sets the control width in pixel
  77028. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77029. */
  77030. get widthInPixels(): number;
  77031. set widthInPixels(value: number);
  77032. /**
  77033. * Gets or sets control height
  77034. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77035. */
  77036. get height(): string | number;
  77037. set height(value: string | number);
  77038. /**
  77039. * Gets or sets control height in pixel
  77040. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77041. */
  77042. get heightInPixels(): number;
  77043. set heightInPixels(value: number);
  77044. /** Gets or set font family */
  77045. get fontFamily(): string;
  77046. set fontFamily(value: string);
  77047. /** Gets or sets font style */
  77048. get fontStyle(): string;
  77049. set fontStyle(value: string);
  77050. /** Gets or sets font weight */
  77051. get fontWeight(): string;
  77052. set fontWeight(value: string);
  77053. /**
  77054. * Gets or sets style
  77055. * @see https://doc.babylonjs.com/how_to/gui#styles
  77056. */
  77057. get style(): BABYLON.Nullable<Style>;
  77058. set style(value: BABYLON.Nullable<Style>);
  77059. /** @hidden */
  77060. get _isFontSizeInPercentage(): boolean;
  77061. /** Gets or sets font size in pixels */
  77062. get fontSizeInPixels(): number;
  77063. set fontSizeInPixels(value: number);
  77064. /** Gets or sets font size */
  77065. get fontSize(): string | number;
  77066. set fontSize(value: string | number);
  77067. /** Gets or sets foreground color */
  77068. get color(): string;
  77069. set color(value: string);
  77070. /** Gets or sets z index which is used to reorder controls on the z axis */
  77071. get zIndex(): number;
  77072. set zIndex(value: number);
  77073. /** Gets or sets a boolean indicating if the control can be rendered */
  77074. get notRenderable(): boolean;
  77075. set notRenderable(value: boolean);
  77076. /** Gets or sets a boolean indicating if the control is visible */
  77077. get isVisible(): boolean;
  77078. set isVisible(value: boolean);
  77079. /** Gets a boolean indicating that the control needs to update its rendering */
  77080. get isDirty(): boolean;
  77081. /**
  77082. * Gets the current linked mesh (or null if none)
  77083. */
  77084. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77085. /**
  77086. * Gets or sets a value indicating the padding to use on the left of the control
  77087. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77088. */
  77089. get paddingLeft(): string | number;
  77090. set paddingLeft(value: string | number);
  77091. /**
  77092. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77093. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77094. */
  77095. get paddingLeftInPixels(): number;
  77096. set paddingLeftInPixels(value: number);
  77097. /**
  77098. * Gets or sets a value indicating the padding to use on the right of the control
  77099. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77100. */
  77101. get paddingRight(): string | number;
  77102. set paddingRight(value: string | number);
  77103. /**
  77104. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77105. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77106. */
  77107. get paddingRightInPixels(): number;
  77108. set paddingRightInPixels(value: number);
  77109. /**
  77110. * Gets or sets a value indicating the padding to use on the top of the control
  77111. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77112. */
  77113. get paddingTop(): string | number;
  77114. set paddingTop(value: string | number);
  77115. /**
  77116. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77117. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77118. */
  77119. get paddingTopInPixels(): number;
  77120. set paddingTopInPixels(value: number);
  77121. /**
  77122. * Gets or sets a value indicating the padding to use on the bottom of the control
  77123. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77124. */
  77125. get paddingBottom(): string | number;
  77126. set paddingBottom(value: string | number);
  77127. /**
  77128. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77129. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77130. */
  77131. get paddingBottomInPixels(): number;
  77132. set paddingBottomInPixels(value: number);
  77133. /**
  77134. * Gets or sets a value indicating the left coordinate of the control
  77135. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77136. */
  77137. get left(): string | number;
  77138. set left(value: string | number);
  77139. /**
  77140. * Gets or sets a value indicating the left coordinate in pixels of the control
  77141. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77142. */
  77143. get leftInPixels(): number;
  77144. set leftInPixels(value: number);
  77145. /**
  77146. * Gets or sets a value indicating the top coordinate of the control
  77147. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77148. */
  77149. get top(): string | number;
  77150. set top(value: string | number);
  77151. /**
  77152. * Gets or sets a value indicating the top coordinate in pixels of the control
  77153. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77154. */
  77155. get topInPixels(): number;
  77156. set topInPixels(value: number);
  77157. /**
  77158. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77159. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77160. */
  77161. get linkOffsetX(): string | number;
  77162. set linkOffsetX(value: string | number);
  77163. /**
  77164. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77165. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77166. */
  77167. get linkOffsetXInPixels(): number;
  77168. set linkOffsetXInPixels(value: number);
  77169. /**
  77170. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77171. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77172. */
  77173. get linkOffsetY(): string | number;
  77174. set linkOffsetY(value: string | number);
  77175. /**
  77176. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77177. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77178. */
  77179. get linkOffsetYInPixels(): number;
  77180. set linkOffsetYInPixels(value: number);
  77181. /** Gets the center coordinate on X axis */
  77182. get centerX(): number;
  77183. /** Gets the center coordinate on Y axis */
  77184. get centerY(): number;
  77185. /** Gets or sets if control is Enabled*/
  77186. get isEnabled(): boolean;
  77187. set isEnabled(value: boolean);
  77188. /** Gets or sets background color of control if it's disabled*/
  77189. get disabledColor(): string;
  77190. set disabledColor(value: string);
  77191. /** Gets or sets front color of control if it's disabled*/
  77192. get disabledColorItem(): string;
  77193. set disabledColorItem(value: string);
  77194. /**
  77195. * Creates a new control
  77196. * @param name defines the name of the control
  77197. */
  77198. constructor(
  77199. /** defines the name of the control */
  77200. name?: string | undefined);
  77201. /** @hidden */
  77202. protected _getTypeName(): string;
  77203. /**
  77204. * Gets the first ascendant in the hierarchy of the given type
  77205. * @param className defines the required type
  77206. * @returns the ascendant or null if not found
  77207. */
  77208. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77209. /** @hidden */
  77210. _resetFontCache(): void;
  77211. /**
  77212. * Determines if a container is an ascendant of the current control
  77213. * @param container defines the container to look for
  77214. * @returns true if the container is one of the ascendant of the control
  77215. */
  77216. isAscendant(container: Control): boolean;
  77217. /**
  77218. * Gets coordinates in local control space
  77219. * @param globalCoordinates defines the coordinates to transform
  77220. * @returns the new coordinates in local space
  77221. */
  77222. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77223. /**
  77224. * Gets coordinates in local control space
  77225. * @param globalCoordinates defines the coordinates to transform
  77226. * @param result defines the target vector2 where to store the result
  77227. * @returns the current control
  77228. */
  77229. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77230. /**
  77231. * Gets coordinates in parent local control space
  77232. * @param globalCoordinates defines the coordinates to transform
  77233. * @returns the new coordinates in parent local space
  77234. */
  77235. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77236. /**
  77237. * Move the current control to a vector3 position projected onto the screen.
  77238. * @param position defines the target position
  77239. * @param scene defines the hosting scene
  77240. */
  77241. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77242. /**
  77243. * Will store all controls that have this control as ascendant in a given array
  77244. * @param results defines the array where to store the descendants
  77245. * @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
  77246. * @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
  77247. */
  77248. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77249. /**
  77250. * Will return all controls that have this control as ascendant
  77251. * @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
  77252. * @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
  77253. * @return all child controls
  77254. */
  77255. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77256. /**
  77257. * Link current control with a target mesh
  77258. * @param mesh defines the mesh to link with
  77259. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77260. */
  77261. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77262. /** @hidden */
  77263. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77264. /** @hidden */
  77265. _offsetLeft(offset: number): void;
  77266. /** @hidden */
  77267. _offsetTop(offset: number): void;
  77268. /** @hidden */
  77269. _markMatrixAsDirty(): void;
  77270. /** @hidden */
  77271. _flagDescendantsAsMatrixDirty(): void;
  77272. /** @hidden */
  77273. _intersectsRect(rect: Measure): boolean;
  77274. /** @hidden */
  77275. protected invalidateRect(): void;
  77276. /** @hidden */
  77277. _markAsDirty(force?: boolean): void;
  77278. /** @hidden */
  77279. _markAllAsDirty(): void;
  77280. /** @hidden */
  77281. _link(host: AdvancedDynamicTexture): void;
  77282. /** @hidden */
  77283. protected _transform(context?: CanvasRenderingContext2D): void;
  77284. /** @hidden */
  77285. _renderHighlight(context: CanvasRenderingContext2D): void;
  77286. /** @hidden */
  77287. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77288. /** @hidden */
  77289. protected _applyStates(context: CanvasRenderingContext2D): void;
  77290. /** @hidden */
  77291. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77292. /** @hidden */
  77293. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77294. protected _evaluateClippingState(parentMeasure: Measure): void;
  77295. /** @hidden */
  77296. _measure(): void;
  77297. /** @hidden */
  77298. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77299. /** @hidden */
  77300. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77301. /** @hidden */
  77302. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77303. /** @hidden */
  77304. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77305. private static _ClipMeasure;
  77306. private _tmpMeasureA;
  77307. private _clip;
  77308. /** @hidden */
  77309. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77310. /** @hidden */
  77311. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77312. /**
  77313. * Tests if a given coordinates belong to the current control
  77314. * @param x defines x coordinate to test
  77315. * @param y defines y coordinate to test
  77316. * @returns true if the coordinates are inside the control
  77317. */
  77318. contains(x: number, y: number): boolean;
  77319. /** @hidden */
  77320. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77321. /** @hidden */
  77322. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77323. /** @hidden */
  77324. _onPointerEnter(target: Control): boolean;
  77325. /** @hidden */
  77326. _onPointerOut(target: Control, force?: boolean): void;
  77327. /** @hidden */
  77328. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77329. /** @hidden */
  77330. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77331. /** @hidden */
  77332. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77333. /** @hidden */
  77334. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77335. /** @hidden */
  77336. _onCanvasBlur(): void;
  77337. /** @hidden */
  77338. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77339. private _prepareFont;
  77340. /** Releases associated resources */
  77341. dispose(): void;
  77342. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77343. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77344. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77345. private static _VERTICAL_ALIGNMENT_TOP;
  77346. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77347. private static _VERTICAL_ALIGNMENT_CENTER;
  77348. /** HORIZONTAL_ALIGNMENT_LEFT */
  77349. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77350. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77351. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77352. /** HORIZONTAL_ALIGNMENT_CENTER */
  77353. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77354. /** VERTICAL_ALIGNMENT_TOP */
  77355. static get VERTICAL_ALIGNMENT_TOP(): number;
  77356. /** VERTICAL_ALIGNMENT_BOTTOM */
  77357. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77358. /** VERTICAL_ALIGNMENT_CENTER */
  77359. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77360. private static _FontHeightSizes;
  77361. /** @hidden */
  77362. static _GetFontOffset(font: string): {
  77363. ascent: number;
  77364. height: number;
  77365. descent: number;
  77366. };
  77367. /**
  77368. * Creates a stack panel that can be used to render headers
  77369. * @param control defines the control to associate with the header
  77370. * @param text defines the text of the header
  77371. * @param size defines the size of the header
  77372. * @param options defines options used to configure the header
  77373. * @returns a new StackPanel
  77374. * @ignore
  77375. * @hidden
  77376. */
  77377. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77378. isHorizontal: boolean;
  77379. controlFirst: boolean;
  77380. }) => any;
  77381. /** @hidden */
  77382. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77383. }
  77384. }
  77385. declare module BABYLON.GUI {
  77386. /**
  77387. * Root class for 2D containers
  77388. * @see https://doc.babylonjs.com/how_to/gui#containers
  77389. */
  77390. export class Container extends Control {
  77391. name?: string | undefined;
  77392. /** @hidden */
  77393. _children: Control[];
  77394. /** @hidden */
  77395. protected _measureForChildren: Measure;
  77396. /** @hidden */
  77397. protected _background: string;
  77398. /** @hidden */
  77399. protected _adaptWidthToChildren: boolean;
  77400. /** @hidden */
  77401. protected _adaptHeightToChildren: boolean;
  77402. /**
  77403. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77404. */
  77405. logLayoutCycleErrors: boolean;
  77406. /**
  77407. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77408. */
  77409. maxLayoutCycle: number;
  77410. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77411. get adaptHeightToChildren(): boolean;
  77412. set adaptHeightToChildren(value: boolean);
  77413. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77414. get adaptWidthToChildren(): boolean;
  77415. set adaptWidthToChildren(value: boolean);
  77416. /** Gets or sets background color */
  77417. get background(): string;
  77418. set background(value: string);
  77419. /** Gets the list of children */
  77420. get children(): Control[];
  77421. /**
  77422. * Creates a new Container
  77423. * @param name defines the name of the container
  77424. */
  77425. constructor(name?: string | undefined);
  77426. protected _getTypeName(): string;
  77427. _flagDescendantsAsMatrixDirty(): void;
  77428. /**
  77429. * Gets a child using its name
  77430. * @param name defines the child name to look for
  77431. * @returns the child control if found
  77432. */
  77433. getChildByName(name: string): BABYLON.Nullable<Control>;
  77434. /**
  77435. * Gets a child using its type and its name
  77436. * @param name defines the child name to look for
  77437. * @param type defines the child type to look for
  77438. * @returns the child control if found
  77439. */
  77440. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77441. /**
  77442. * Search for a specific control in children
  77443. * @param control defines the control to look for
  77444. * @returns true if the control is in child list
  77445. */
  77446. containsControl(control: Control): boolean;
  77447. /**
  77448. * Adds a new control to the current container
  77449. * @param control defines the control to add
  77450. * @returns the current container
  77451. */
  77452. addControl(control: BABYLON.Nullable<Control>): Container;
  77453. /**
  77454. * Removes all controls from the current container
  77455. * @returns the current container
  77456. */
  77457. clearControls(): Container;
  77458. /**
  77459. * Removes a control from the current container
  77460. * @param control defines the control to remove
  77461. * @returns the current container
  77462. */
  77463. removeControl(control: Control): Container;
  77464. /** @hidden */
  77465. _reOrderControl(control: Control): void;
  77466. /** @hidden */
  77467. _offsetLeft(offset: number): void;
  77468. /** @hidden */
  77469. _offsetTop(offset: number): void;
  77470. /** @hidden */
  77471. _markAllAsDirty(): void;
  77472. /** @hidden */
  77473. protected _localDraw(context: CanvasRenderingContext2D): void;
  77474. /** @hidden */
  77475. _link(host: AdvancedDynamicTexture): void;
  77476. /** @hidden */
  77477. protected _beforeLayout(): void;
  77478. /** @hidden */
  77479. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77480. /** @hidden */
  77481. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77482. protected _postMeasure(): void;
  77483. /** @hidden */
  77484. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77485. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77486. /** @hidden */
  77487. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77488. /** @hidden */
  77489. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77490. /** Releases associated resources */
  77491. dispose(): void;
  77492. }
  77493. }
  77494. declare module BABYLON.GUI {
  77495. /** Class used to create rectangle container */
  77496. export class Rectangle extends Container {
  77497. name?: string | undefined;
  77498. private _thickness;
  77499. private _cornerRadius;
  77500. /** Gets or sets border thickness */
  77501. get thickness(): number;
  77502. set thickness(value: number);
  77503. /** Gets or sets the corner radius angle */
  77504. get cornerRadius(): number;
  77505. set cornerRadius(value: number);
  77506. /**
  77507. * Creates a new Rectangle
  77508. * @param name defines the control name
  77509. */
  77510. constructor(name?: string | undefined);
  77511. protected _getTypeName(): string;
  77512. protected _localDraw(context: CanvasRenderingContext2D): void;
  77513. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77514. private _drawRoundedRect;
  77515. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77516. }
  77517. }
  77518. declare module BABYLON.GUI {
  77519. /**
  77520. * Enum that determines the text-wrapping mode to use.
  77521. */
  77522. export enum TextWrapping {
  77523. /**
  77524. * Clip the text when it's larger than Control.width; this is the default mode.
  77525. */
  77526. Clip = 0,
  77527. /**
  77528. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77529. */
  77530. WordWrap = 1,
  77531. /**
  77532. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77533. */
  77534. Ellipsis = 2
  77535. }
  77536. /**
  77537. * Class used to create text block control
  77538. */
  77539. export class TextBlock extends Control {
  77540. /**
  77541. * Defines the name of the control
  77542. */
  77543. name?: string | undefined;
  77544. private _text;
  77545. private _textWrapping;
  77546. private _textHorizontalAlignment;
  77547. private _textVerticalAlignment;
  77548. private _lines;
  77549. private _resizeToFit;
  77550. private _lineSpacing;
  77551. private _outlineWidth;
  77552. private _outlineColor;
  77553. private _underline;
  77554. private _lineThrough;
  77555. /**
  77556. * An event triggered after the text is changed
  77557. */
  77558. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77559. /**
  77560. * An event triggered after the text was broken up into lines
  77561. */
  77562. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77563. /**
  77564. * Function used to split a string into words. By default, a string is split at each space character found
  77565. */
  77566. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77567. /**
  77568. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77569. */
  77570. get lines(): any[];
  77571. /**
  77572. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77573. */
  77574. get resizeToFit(): boolean;
  77575. /**
  77576. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77577. */
  77578. set resizeToFit(value: boolean);
  77579. /**
  77580. * Gets or sets a boolean indicating if text must be wrapped
  77581. */
  77582. get textWrapping(): TextWrapping | boolean;
  77583. /**
  77584. * Gets or sets a boolean indicating if text must be wrapped
  77585. */
  77586. set textWrapping(value: TextWrapping | boolean);
  77587. /**
  77588. * Gets or sets text to display
  77589. */
  77590. get text(): string;
  77591. /**
  77592. * Gets or sets text to display
  77593. */
  77594. set text(value: string);
  77595. /**
  77596. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77597. */
  77598. get textHorizontalAlignment(): number;
  77599. /**
  77600. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77601. */
  77602. set textHorizontalAlignment(value: number);
  77603. /**
  77604. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77605. */
  77606. get textVerticalAlignment(): number;
  77607. /**
  77608. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77609. */
  77610. set textVerticalAlignment(value: number);
  77611. /**
  77612. * Gets or sets line spacing value
  77613. */
  77614. set lineSpacing(value: string | number);
  77615. /**
  77616. * Gets or sets line spacing value
  77617. */
  77618. get lineSpacing(): string | number;
  77619. /**
  77620. * Gets or sets outlineWidth of the text to display
  77621. */
  77622. get outlineWidth(): number;
  77623. /**
  77624. * Gets or sets outlineWidth of the text to display
  77625. */
  77626. set outlineWidth(value: number);
  77627. /**
  77628. * Gets or sets a boolean indicating that text must have underline
  77629. */
  77630. get underline(): boolean;
  77631. /**
  77632. * Gets or sets a boolean indicating that text must have underline
  77633. */
  77634. set underline(value: boolean);
  77635. /**
  77636. * Gets or sets an boolean indicating that text must be crossed out
  77637. */
  77638. get lineThrough(): boolean;
  77639. /**
  77640. * Gets or sets an boolean indicating that text must be crossed out
  77641. */
  77642. set lineThrough(value: boolean);
  77643. /**
  77644. * Gets or sets outlineColor of the text to display
  77645. */
  77646. get outlineColor(): string;
  77647. /**
  77648. * Gets or sets outlineColor of the text to display
  77649. */
  77650. set outlineColor(value: string);
  77651. /**
  77652. * Creates a new TextBlock object
  77653. * @param name defines the name of the control
  77654. * @param text defines the text to display (emptry string by default)
  77655. */
  77656. constructor(
  77657. /**
  77658. * Defines the name of the control
  77659. */
  77660. name?: string | undefined, text?: string);
  77661. protected _getTypeName(): string;
  77662. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77663. private _drawText;
  77664. /** @hidden */
  77665. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77666. protected _applyStates(context: CanvasRenderingContext2D): void;
  77667. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77668. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77669. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77670. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77671. protected _renderLines(context: CanvasRenderingContext2D): void;
  77672. /**
  77673. * Given a width constraint applied on the text block, find the expected height
  77674. * @returns expected height
  77675. */
  77676. computeExpectedHeight(): number;
  77677. dispose(): void;
  77678. }
  77679. }
  77680. declare module BABYLON.GUI {
  77681. /**
  77682. * Class used to create 2D images
  77683. */
  77684. export class Image extends Control {
  77685. name?: string | undefined;
  77686. private _workingCanvas;
  77687. private _domImage;
  77688. private _imageWidth;
  77689. private _imageHeight;
  77690. private _loaded;
  77691. private _stretch;
  77692. private _source;
  77693. private _autoScale;
  77694. private _sourceLeft;
  77695. private _sourceTop;
  77696. private _sourceWidth;
  77697. private _sourceHeight;
  77698. private _svgAttributesComputationCompleted;
  77699. private _isSVG;
  77700. private _cellWidth;
  77701. private _cellHeight;
  77702. private _cellId;
  77703. private _populateNinePatchSlicesFromImage;
  77704. private _sliceLeft;
  77705. private _sliceRight;
  77706. private _sliceTop;
  77707. private _sliceBottom;
  77708. private _detectPointerOnOpaqueOnly;
  77709. private _imageDataCache;
  77710. /**
  77711. * BABYLON.Observable notified when the content is loaded
  77712. */
  77713. onImageLoadedObservable: BABYLON.Observable<Image>;
  77714. /**
  77715. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77716. */
  77717. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77718. /**
  77719. * Gets a boolean indicating that the content is loaded
  77720. */
  77721. get isLoaded(): boolean;
  77722. /**
  77723. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77724. */
  77725. get populateNinePatchSlicesFromImage(): boolean;
  77726. set populateNinePatchSlicesFromImage(value: boolean);
  77727. /**
  77728. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77729. * Beware using this as this will comsume more memory as the image has to be stored twice
  77730. */
  77731. get detectPointerOnOpaqueOnly(): boolean;
  77732. set detectPointerOnOpaqueOnly(value: boolean);
  77733. /**
  77734. * Gets or sets the left value for slicing (9-patch)
  77735. */
  77736. get sliceLeft(): number;
  77737. set sliceLeft(value: number);
  77738. /**
  77739. * Gets or sets the right value for slicing (9-patch)
  77740. */
  77741. get sliceRight(): number;
  77742. set sliceRight(value: number);
  77743. /**
  77744. * Gets or sets the top value for slicing (9-patch)
  77745. */
  77746. get sliceTop(): number;
  77747. set sliceTop(value: number);
  77748. /**
  77749. * Gets or sets the bottom value for slicing (9-patch)
  77750. */
  77751. get sliceBottom(): number;
  77752. set sliceBottom(value: number);
  77753. /**
  77754. * Gets or sets the left coordinate in the source image
  77755. */
  77756. get sourceLeft(): number;
  77757. set sourceLeft(value: number);
  77758. /**
  77759. * Gets or sets the top coordinate in the source image
  77760. */
  77761. get sourceTop(): number;
  77762. set sourceTop(value: number);
  77763. /**
  77764. * Gets or sets the width to capture in the source image
  77765. */
  77766. get sourceWidth(): number;
  77767. set sourceWidth(value: number);
  77768. /**
  77769. * Gets or sets the height to capture in the source image
  77770. */
  77771. get sourceHeight(): number;
  77772. set sourceHeight(value: number);
  77773. /** Indicates if the format of the image is SVG */
  77774. get isSVG(): boolean;
  77775. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77776. get svgAttributesComputationCompleted(): boolean;
  77777. /**
  77778. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77779. * @see https://doc.babylonjs.com/how_to/gui#image
  77780. */
  77781. get autoScale(): boolean;
  77782. set autoScale(value: boolean);
  77783. /** Gets or sets the streching mode used by the image */
  77784. get stretch(): number;
  77785. set stretch(value: number);
  77786. /** @hidden */
  77787. _rotate90(n: number, preserveProperties?: boolean): Image;
  77788. private _handleRotationForSVGImage;
  77789. private _rotate90SourceProperties;
  77790. /**
  77791. * Gets or sets the internal DOM image used to render the control
  77792. */
  77793. set domImage(value: HTMLImageElement);
  77794. get domImage(): HTMLImageElement;
  77795. private _onImageLoaded;
  77796. private _extractNinePatchSliceDataFromImage;
  77797. /**
  77798. * Gets or sets image source url
  77799. */
  77800. set source(value: BABYLON.Nullable<string>);
  77801. /**
  77802. * Checks for svg document with icon id present
  77803. */
  77804. private _svgCheck;
  77805. /**
  77806. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77807. * given external svg file and icon id
  77808. */
  77809. private _getSVGAttribs;
  77810. /**
  77811. * Gets or sets the cell width to use when animation sheet is enabled
  77812. * @see https://doc.babylonjs.com/how_to/gui#image
  77813. */
  77814. get cellWidth(): number;
  77815. set cellWidth(value: number);
  77816. /**
  77817. * Gets or sets the cell height to use when animation sheet is enabled
  77818. * @see https://doc.babylonjs.com/how_to/gui#image
  77819. */
  77820. get cellHeight(): number;
  77821. set cellHeight(value: number);
  77822. /**
  77823. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77824. * @see https://doc.babylonjs.com/how_to/gui#image
  77825. */
  77826. get cellId(): number;
  77827. set cellId(value: number);
  77828. /**
  77829. * Creates a new Image
  77830. * @param name defines the control name
  77831. * @param url defines the image url
  77832. */
  77833. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77834. /**
  77835. * Tests if a given coordinates belong to the current control
  77836. * @param x defines x coordinate to test
  77837. * @param y defines y coordinate to test
  77838. * @returns true if the coordinates are inside the control
  77839. */
  77840. contains(x: number, y: number): boolean;
  77841. protected _getTypeName(): string;
  77842. /** Force the control to synchronize with its content */
  77843. synchronizeSizeWithContent(): void;
  77844. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77845. private _prepareWorkingCanvasForOpaqueDetection;
  77846. private _drawImage;
  77847. _draw(context: CanvasRenderingContext2D): void;
  77848. private _renderCornerPatch;
  77849. private _renderNinePatch;
  77850. dispose(): void;
  77851. /** STRETCH_NONE */
  77852. static readonly STRETCH_NONE: number;
  77853. /** STRETCH_FILL */
  77854. static readonly STRETCH_FILL: number;
  77855. /** STRETCH_UNIFORM */
  77856. static readonly STRETCH_UNIFORM: number;
  77857. /** STRETCH_EXTEND */
  77858. static readonly STRETCH_EXTEND: number;
  77859. /** NINE_PATCH */
  77860. static readonly STRETCH_NINE_PATCH: number;
  77861. }
  77862. }
  77863. declare module BABYLON.GUI {
  77864. /**
  77865. * Class used to create 2D buttons
  77866. */
  77867. export class Button extends Rectangle {
  77868. name?: string | undefined;
  77869. /**
  77870. * Function called to generate a pointer enter animation
  77871. */
  77872. pointerEnterAnimation: () => void;
  77873. /**
  77874. * Function called to generate a pointer out animation
  77875. */
  77876. pointerOutAnimation: () => void;
  77877. /**
  77878. * Function called to generate a pointer down animation
  77879. */
  77880. pointerDownAnimation: () => void;
  77881. /**
  77882. * Function called to generate a pointer up animation
  77883. */
  77884. pointerUpAnimation: () => void;
  77885. /**
  77886. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77887. */
  77888. delegatePickingToChildren: boolean;
  77889. private _image;
  77890. /**
  77891. * Returns the image part of the button (if any)
  77892. */
  77893. get image(): BABYLON.Nullable<Image>;
  77894. private _textBlock;
  77895. /**
  77896. * Returns the image part of the button (if any)
  77897. */
  77898. get textBlock(): BABYLON.Nullable<TextBlock>;
  77899. /**
  77900. * Creates a new Button
  77901. * @param name defines the name of the button
  77902. */
  77903. constructor(name?: string | undefined);
  77904. protected _getTypeName(): string;
  77905. /** @hidden */
  77906. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77907. /** @hidden */
  77908. _onPointerEnter(target: Control): boolean;
  77909. /** @hidden */
  77910. _onPointerOut(target: Control, force?: boolean): void;
  77911. /** @hidden */
  77912. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77913. /** @hidden */
  77914. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77915. /**
  77916. * Creates a new button made with an image and a text
  77917. * @param name defines the name of the button
  77918. * @param text defines the text of the button
  77919. * @param imageUrl defines the url of the image
  77920. * @returns a new Button
  77921. */
  77922. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77923. /**
  77924. * Creates a new button made with an image
  77925. * @param name defines the name of the button
  77926. * @param imageUrl defines the url of the image
  77927. * @returns a new Button
  77928. */
  77929. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77930. /**
  77931. * Creates a new button made with a text
  77932. * @param name defines the name of the button
  77933. * @param text defines the text of the button
  77934. * @returns a new Button
  77935. */
  77936. static CreateSimpleButton(name: string, text: string): Button;
  77937. /**
  77938. * Creates a new button made with an image and a centered text
  77939. * @param name defines the name of the button
  77940. * @param text defines the text of the button
  77941. * @param imageUrl defines the url of the image
  77942. * @returns a new Button
  77943. */
  77944. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77945. }
  77946. }
  77947. declare module BABYLON.GUI {
  77948. /**
  77949. * Class used to create a 2D stack panel container
  77950. */
  77951. export class StackPanel extends Container {
  77952. name?: string | undefined;
  77953. private _isVertical;
  77954. private _manualWidth;
  77955. private _manualHeight;
  77956. private _doNotTrackManualChanges;
  77957. /**
  77958. * Gets or sets a boolean indicating that layou warnings should be ignored
  77959. */
  77960. ignoreLayoutWarnings: boolean;
  77961. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77962. get isVertical(): boolean;
  77963. set isVertical(value: boolean);
  77964. /**
  77965. * Gets or sets panel width.
  77966. * This value should not be set when in horizontal mode as it will be computed automatically
  77967. */
  77968. set width(value: string | number);
  77969. get width(): string | number;
  77970. /**
  77971. * Gets or sets panel height.
  77972. * This value should not be set when in vertical mode as it will be computed automatically
  77973. */
  77974. set height(value: string | number);
  77975. get height(): string | number;
  77976. /**
  77977. * Creates a new StackPanel
  77978. * @param name defines control name
  77979. */
  77980. constructor(name?: string | undefined);
  77981. protected _getTypeName(): string;
  77982. /** @hidden */
  77983. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77984. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77985. protected _postMeasure(): void;
  77986. }
  77987. }
  77988. declare module BABYLON.GUI {
  77989. /**
  77990. * Class used to represent a 2D checkbox
  77991. */
  77992. export class Checkbox extends Control {
  77993. name?: string | undefined;
  77994. private _isChecked;
  77995. private _background;
  77996. private _checkSizeRatio;
  77997. private _thickness;
  77998. /** Gets or sets border thickness */
  77999. get thickness(): number;
  78000. set thickness(value: number);
  78001. /**
  78002. * BABYLON.Observable raised when isChecked property changes
  78003. */
  78004. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78005. /** Gets or sets a value indicating the ratio between overall size and check size */
  78006. get checkSizeRatio(): number;
  78007. set checkSizeRatio(value: number);
  78008. /** Gets or sets background color */
  78009. get background(): string;
  78010. set background(value: string);
  78011. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78012. get isChecked(): boolean;
  78013. set isChecked(value: boolean);
  78014. /**
  78015. * Creates a new CheckBox
  78016. * @param name defines the control name
  78017. */
  78018. constructor(name?: string | undefined);
  78019. protected _getTypeName(): string;
  78020. /** @hidden */
  78021. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78022. /** @hidden */
  78023. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78024. /**
  78025. * Utility function to easily create a checkbox with a header
  78026. * @param title defines the label to use for the header
  78027. * @param onValueChanged defines the callback to call when value changes
  78028. * @returns a StackPanel containing the checkbox and a textBlock
  78029. */
  78030. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78031. }
  78032. }
  78033. declare module BABYLON.GUI {
  78034. /**
  78035. * Class used to store key control properties
  78036. */
  78037. export class KeyPropertySet {
  78038. /** Width */
  78039. width?: string;
  78040. /** Height */
  78041. height?: string;
  78042. /** Left padding */
  78043. paddingLeft?: string;
  78044. /** Right padding */
  78045. paddingRight?: string;
  78046. /** Top padding */
  78047. paddingTop?: string;
  78048. /** Bottom padding */
  78049. paddingBottom?: string;
  78050. /** Foreground color */
  78051. color?: string;
  78052. /** Background color */
  78053. background?: string;
  78054. }
  78055. /**
  78056. * Class used to create virtual keyboard
  78057. */
  78058. export class VirtualKeyboard extends StackPanel {
  78059. /** BABYLON.Observable raised when a key is pressed */
  78060. onKeyPressObservable: BABYLON.Observable<string>;
  78061. /** Gets or sets default key button width */
  78062. defaultButtonWidth: string;
  78063. /** Gets or sets default key button height */
  78064. defaultButtonHeight: string;
  78065. /** Gets or sets default key button left padding */
  78066. defaultButtonPaddingLeft: string;
  78067. /** Gets or sets default key button right padding */
  78068. defaultButtonPaddingRight: string;
  78069. /** Gets or sets default key button top padding */
  78070. defaultButtonPaddingTop: string;
  78071. /** Gets or sets default key button bottom padding */
  78072. defaultButtonPaddingBottom: string;
  78073. /** Gets or sets default key button foreground color */
  78074. defaultButtonColor: string;
  78075. /** Gets or sets default key button background color */
  78076. defaultButtonBackground: string;
  78077. /** Gets or sets shift button foreground color */
  78078. shiftButtonColor: string;
  78079. /** Gets or sets shift button thickness*/
  78080. selectedShiftThickness: number;
  78081. /** Gets shift key state */
  78082. shiftState: number;
  78083. protected _getTypeName(): string;
  78084. private _createKey;
  78085. /**
  78086. * Adds a new row of keys
  78087. * @param keys defines the list of keys to add
  78088. * @param propertySets defines the associated property sets
  78089. */
  78090. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78091. /**
  78092. * Set the shift key to a specific state
  78093. * @param shiftState defines the new shift state
  78094. */
  78095. applyShiftState(shiftState: number): void;
  78096. private _currentlyConnectedInputText;
  78097. private _connectedInputTexts;
  78098. private _onKeyPressObserver;
  78099. /** Gets the input text control currently attached to the keyboard */
  78100. get connectedInputText(): BABYLON.Nullable<InputText>;
  78101. /**
  78102. * Connects the keyboard with an input text control
  78103. *
  78104. * @param input defines the target control
  78105. */
  78106. connect(input: InputText): void;
  78107. /**
  78108. * Disconnects the keyboard from connected InputText controls
  78109. *
  78110. * @param input optionally defines a target control, otherwise all are disconnected
  78111. */
  78112. disconnect(input?: InputText): void;
  78113. private _removeConnectedInputObservables;
  78114. /**
  78115. * Release all resources
  78116. */
  78117. dispose(): void;
  78118. /**
  78119. * Creates a new keyboard using a default layout
  78120. *
  78121. * @param name defines control name
  78122. * @returns a new VirtualKeyboard
  78123. */
  78124. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78125. }
  78126. }
  78127. declare module BABYLON.GUI {
  78128. /**
  78129. * Class used to create input text control
  78130. */
  78131. export class InputText extends Control implements IFocusableControl {
  78132. name?: string | undefined;
  78133. private _text;
  78134. private _placeholderText;
  78135. private _background;
  78136. private _focusedBackground;
  78137. private _focusedColor;
  78138. private _placeholderColor;
  78139. private _thickness;
  78140. private _margin;
  78141. private _autoStretchWidth;
  78142. private _maxWidth;
  78143. private _isFocused;
  78144. private _blinkTimeout;
  78145. private _blinkIsEven;
  78146. private _cursorOffset;
  78147. private _scrollLeft;
  78148. private _textWidth;
  78149. private _clickedCoordinate;
  78150. private _deadKey;
  78151. private _addKey;
  78152. private _currentKey;
  78153. private _isTextHighlightOn;
  78154. private _textHighlightColor;
  78155. private _highligherOpacity;
  78156. private _highlightedText;
  78157. private _startHighlightIndex;
  78158. private _endHighlightIndex;
  78159. private _cursorIndex;
  78160. private _onFocusSelectAll;
  78161. private _isPointerDown;
  78162. private _onClipboardObserver;
  78163. private _onPointerDblTapObserver;
  78164. /** @hidden */
  78165. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78166. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78167. promptMessage: string;
  78168. /** Force disable prompt on mobile device */
  78169. disableMobilePrompt: boolean;
  78170. /** BABYLON.Observable raised when the text changes */
  78171. onTextChangedObservable: BABYLON.Observable<InputText>;
  78172. /** BABYLON.Observable raised just before an entered character is to be added */
  78173. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78174. /** BABYLON.Observable raised when the control gets the focus */
  78175. onFocusObservable: BABYLON.Observable<InputText>;
  78176. /** BABYLON.Observable raised when the control loses the focus */
  78177. onBlurObservable: BABYLON.Observable<InputText>;
  78178. /**Observable raised when the text is highlighted */
  78179. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78180. /**Observable raised when copy event is triggered */
  78181. onTextCopyObservable: BABYLON.Observable<InputText>;
  78182. /** BABYLON.Observable raised when cut event is triggered */
  78183. onTextCutObservable: BABYLON.Observable<InputText>;
  78184. /** BABYLON.Observable raised when paste event is triggered */
  78185. onTextPasteObservable: BABYLON.Observable<InputText>;
  78186. /** BABYLON.Observable raised when a key event was processed */
  78187. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78188. /** Gets or sets the maximum width allowed by the control */
  78189. get maxWidth(): string | number;
  78190. /** Gets the maximum width allowed by the control in pixels */
  78191. get maxWidthInPixels(): number;
  78192. set maxWidth(value: string | number);
  78193. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78194. get highligherOpacity(): number;
  78195. set highligherOpacity(value: number);
  78196. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78197. get onFocusSelectAll(): boolean;
  78198. set onFocusSelectAll(value: boolean);
  78199. /** Gets or sets the text hightlight color */
  78200. get textHighlightColor(): string;
  78201. set textHighlightColor(value: string);
  78202. /** Gets or sets control margin */
  78203. get margin(): string;
  78204. /** Gets control margin in pixels */
  78205. get marginInPixels(): number;
  78206. set margin(value: string);
  78207. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78208. get autoStretchWidth(): boolean;
  78209. set autoStretchWidth(value: boolean);
  78210. /** Gets or sets border thickness */
  78211. get thickness(): number;
  78212. set thickness(value: number);
  78213. /** Gets or sets the background color when focused */
  78214. get focusedBackground(): string;
  78215. set focusedBackground(value: string);
  78216. /** Gets or sets the background color when focused */
  78217. get focusedColor(): string;
  78218. set focusedColor(value: string);
  78219. /** Gets or sets the background color */
  78220. get background(): string;
  78221. set background(value: string);
  78222. /** Gets or sets the placeholder color */
  78223. get placeholderColor(): string;
  78224. set placeholderColor(value: string);
  78225. /** Gets or sets the text displayed when the control is empty */
  78226. get placeholderText(): string;
  78227. set placeholderText(value: string);
  78228. /** Gets or sets the dead key flag */
  78229. get deadKey(): boolean;
  78230. set deadKey(flag: boolean);
  78231. /** Gets or sets the highlight text */
  78232. get highlightedText(): string;
  78233. set highlightedText(text: string);
  78234. /** Gets or sets if the current key should be added */
  78235. get addKey(): boolean;
  78236. set addKey(flag: boolean);
  78237. /** Gets or sets the value of the current key being entered */
  78238. get currentKey(): string;
  78239. set currentKey(key: string);
  78240. /** Gets or sets the text displayed in the control */
  78241. get text(): string;
  78242. set text(value: string);
  78243. /** Gets or sets control width */
  78244. get width(): string | number;
  78245. set width(value: string | number);
  78246. /**
  78247. * Creates a new InputText
  78248. * @param name defines the control name
  78249. * @param text defines the text of the control
  78250. */
  78251. constructor(name?: string | undefined, text?: string);
  78252. /** @hidden */
  78253. onBlur(): void;
  78254. /** @hidden */
  78255. onFocus(): void;
  78256. protected _getTypeName(): string;
  78257. /**
  78258. * Function called to get the list of controls that should not steal the focus from this control
  78259. * @returns an array of controls
  78260. */
  78261. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78262. /** @hidden */
  78263. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78264. /** @hidden */
  78265. private _updateValueFromCursorIndex;
  78266. /** @hidden */
  78267. private _processDblClick;
  78268. /** @hidden */
  78269. private _selectAllText;
  78270. /**
  78271. * Handles the keyboard event
  78272. * @param evt Defines the KeyboardEvent
  78273. */
  78274. processKeyboard(evt: KeyboardEvent): void;
  78275. /** @hidden */
  78276. private _onCopyText;
  78277. /** @hidden */
  78278. private _onCutText;
  78279. /** @hidden */
  78280. private _onPasteText;
  78281. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78282. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78283. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78284. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78285. protected _beforeRenderText(text: string): string;
  78286. dispose(): void;
  78287. }
  78288. }
  78289. declare module BABYLON.GUI {
  78290. /**
  78291. * Class used to create a 2D grid container
  78292. */
  78293. export class Grid extends Container {
  78294. name?: string | undefined;
  78295. private _rowDefinitions;
  78296. private _columnDefinitions;
  78297. private _cells;
  78298. private _childControls;
  78299. /**
  78300. * Gets the number of columns
  78301. */
  78302. get columnCount(): number;
  78303. /**
  78304. * Gets the number of rows
  78305. */
  78306. get rowCount(): number;
  78307. /** Gets the list of children */
  78308. get children(): Control[];
  78309. /** Gets the list of cells (e.g. the containers) */
  78310. get cells(): {
  78311. [key: string]: Container;
  78312. };
  78313. /**
  78314. * Gets the definition of a specific row
  78315. * @param index defines the index of the row
  78316. * @returns the row definition
  78317. */
  78318. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78319. /**
  78320. * Gets the definition of a specific column
  78321. * @param index defines the index of the column
  78322. * @returns the column definition
  78323. */
  78324. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78325. /**
  78326. * Adds a new row to the grid
  78327. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78328. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78329. * @returns the current grid
  78330. */
  78331. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78332. /**
  78333. * Adds a new column to the grid
  78334. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78335. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78336. * @returns the current grid
  78337. */
  78338. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78339. /**
  78340. * Update a row definition
  78341. * @param index defines the index of the row to update
  78342. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78343. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78344. * @returns the current grid
  78345. */
  78346. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78347. /**
  78348. * Update a column definition
  78349. * @param index defines the index of the column to update
  78350. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78351. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78352. * @returns the current grid
  78353. */
  78354. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78355. /**
  78356. * Gets the list of children stored in a specific cell
  78357. * @param row defines the row to check
  78358. * @param column defines the column to check
  78359. * @returns the list of controls
  78360. */
  78361. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78362. /**
  78363. * Gets a string representing the child cell info (row x column)
  78364. * @param child defines the control to get info from
  78365. * @returns a string containing the child cell info (row x column)
  78366. */
  78367. getChildCellInfo(child: Control): string;
  78368. private _removeCell;
  78369. private _offsetCell;
  78370. /**
  78371. * Remove a column definition at specified index
  78372. * @param index defines the index of the column to remove
  78373. * @returns the current grid
  78374. */
  78375. removeColumnDefinition(index: number): Grid;
  78376. /**
  78377. * Remove a row definition at specified index
  78378. * @param index defines the index of the row to remove
  78379. * @returns the current grid
  78380. */
  78381. removeRowDefinition(index: number): Grid;
  78382. /**
  78383. * Adds a new control to the current grid
  78384. * @param control defines the control to add
  78385. * @param row defines the row where to add the control (0 by default)
  78386. * @param column defines the column where to add the control (0 by default)
  78387. * @returns the current grid
  78388. */
  78389. addControl(control: Control, row?: number, column?: number): Grid;
  78390. /**
  78391. * Removes a control from the current container
  78392. * @param control defines the control to remove
  78393. * @returns the current container
  78394. */
  78395. removeControl(control: Control): Container;
  78396. /**
  78397. * Creates a new Grid
  78398. * @param name defines control name
  78399. */
  78400. constructor(name?: string | undefined);
  78401. protected _getTypeName(): string;
  78402. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78403. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78404. _flagDescendantsAsMatrixDirty(): void;
  78405. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78406. /** Releases associated resources */
  78407. dispose(): void;
  78408. }
  78409. }
  78410. declare module BABYLON.GUI {
  78411. /** Class used to create color pickers */
  78412. export class ColorPicker extends Control {
  78413. name?: string | undefined;
  78414. private static _Epsilon;
  78415. private _colorWheelCanvas;
  78416. private _value;
  78417. private _tmpColor;
  78418. private _pointerStartedOnSquare;
  78419. private _pointerStartedOnWheel;
  78420. private _squareLeft;
  78421. private _squareTop;
  78422. private _squareSize;
  78423. private _h;
  78424. private _s;
  78425. private _v;
  78426. private _lastPointerDownID;
  78427. /**
  78428. * BABYLON.Observable raised when the value changes
  78429. */
  78430. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78431. /** Gets or sets the color of the color picker */
  78432. get value(): BABYLON.Color3;
  78433. set value(value: BABYLON.Color3);
  78434. /**
  78435. * Gets or sets control width
  78436. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78437. */
  78438. get width(): string | number;
  78439. set width(value: string | number);
  78440. /**
  78441. * Gets or sets control height
  78442. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78443. */
  78444. get height(): string | number;
  78445. /** Gets or sets control height */
  78446. set height(value: string | number);
  78447. /** Gets or sets control size */
  78448. get size(): string | number;
  78449. set size(value: string | number);
  78450. /**
  78451. * Creates a new ColorPicker
  78452. * @param name defines the control name
  78453. */
  78454. constructor(name?: string | undefined);
  78455. protected _getTypeName(): string;
  78456. /** @hidden */
  78457. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78458. private _updateSquareProps;
  78459. private _drawGradientSquare;
  78460. private _drawCircle;
  78461. private _createColorWheelCanvas;
  78462. /** @hidden */
  78463. _draw(context: CanvasRenderingContext2D): void;
  78464. private _pointerIsDown;
  78465. private _updateValueFromPointer;
  78466. private _isPointOnSquare;
  78467. private _isPointOnWheel;
  78468. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78469. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78470. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78471. _onCanvasBlur(): void;
  78472. /**
  78473. * This function expands the color picker by creating a color picker dialog with manual
  78474. * color value input and the ability to save colors into an array to be used later in
  78475. * subsequent launches of the dialogue.
  78476. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78477. * @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.
  78478. * @returns picked color as a hex string and the saved colors array as hex strings.
  78479. */
  78480. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78481. pickerWidth?: string;
  78482. pickerHeight?: string;
  78483. headerHeight?: string;
  78484. lastColor?: string;
  78485. swatchLimit?: number;
  78486. numSwatchesPerLine?: number;
  78487. savedColors?: Array<string>;
  78488. }): Promise<{
  78489. savedColors?: string[];
  78490. pickedColor: string;
  78491. }>;
  78492. }
  78493. }
  78494. declare module BABYLON.GUI {
  78495. /** Class used to create 2D ellipse containers */
  78496. export class Ellipse extends Container {
  78497. name?: string | undefined;
  78498. private _thickness;
  78499. /** Gets or sets border thickness */
  78500. get thickness(): number;
  78501. set thickness(value: number);
  78502. /**
  78503. * Creates a new Ellipse
  78504. * @param name defines the control name
  78505. */
  78506. constructor(name?: string | undefined);
  78507. protected _getTypeName(): string;
  78508. protected _localDraw(context: CanvasRenderingContext2D): void;
  78509. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78510. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78511. }
  78512. }
  78513. declare module BABYLON.GUI {
  78514. /**
  78515. * Class used to create a password control
  78516. */
  78517. export class InputPassword extends InputText {
  78518. protected _beforeRenderText(text: string): string;
  78519. }
  78520. }
  78521. declare module BABYLON.GUI {
  78522. /** Class used to render 2D lines */
  78523. export class Line extends Control {
  78524. name?: string | undefined;
  78525. private _lineWidth;
  78526. private _x1;
  78527. private _y1;
  78528. private _x2;
  78529. private _y2;
  78530. private _dash;
  78531. private _connectedControl;
  78532. private _connectedControlDirtyObserver;
  78533. /** Gets or sets the dash pattern */
  78534. get dash(): Array<number>;
  78535. set dash(value: Array<number>);
  78536. /** Gets or sets the control connected with the line end */
  78537. get connectedControl(): Control;
  78538. set connectedControl(value: Control);
  78539. /** Gets or sets start coordinates on X axis */
  78540. get x1(): string | number;
  78541. set x1(value: string | number);
  78542. /** Gets or sets start coordinates on Y axis */
  78543. get y1(): string | number;
  78544. set y1(value: string | number);
  78545. /** Gets or sets end coordinates on X axis */
  78546. get x2(): string | number;
  78547. set x2(value: string | number);
  78548. /** Gets or sets end coordinates on Y axis */
  78549. get y2(): string | number;
  78550. set y2(value: string | number);
  78551. /** Gets or sets line width */
  78552. get lineWidth(): number;
  78553. set lineWidth(value: number);
  78554. /** Gets or sets horizontal alignment */
  78555. set horizontalAlignment(value: number);
  78556. /** Gets or sets vertical alignment */
  78557. set verticalAlignment(value: number);
  78558. private get _effectiveX2();
  78559. private get _effectiveY2();
  78560. /**
  78561. * Creates a new Line
  78562. * @param name defines the control name
  78563. */
  78564. constructor(name?: string | undefined);
  78565. protected _getTypeName(): string;
  78566. _draw(context: CanvasRenderingContext2D): void;
  78567. _measure(): void;
  78568. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78569. /**
  78570. * Move one end of the line given 3D cartesian coordinates.
  78571. * @param position Targeted world position
  78572. * @param scene BABYLON.Scene
  78573. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78574. */
  78575. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78576. /**
  78577. * Move one end of the line to a position in screen absolute space.
  78578. * @param projectedPosition Position in screen absolute space (X, Y)
  78579. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78580. */
  78581. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78582. }
  78583. }
  78584. declare module BABYLON.GUI {
  78585. /**
  78586. * Class used to store a point for a MultiLine object.
  78587. * The point can be pure 2D coordinates, a mesh or a control
  78588. */
  78589. export class MultiLinePoint {
  78590. private _multiLine;
  78591. private _x;
  78592. private _y;
  78593. private _control;
  78594. private _mesh;
  78595. private _controlObserver;
  78596. private _meshObserver;
  78597. /** @hidden */
  78598. _point: BABYLON.Vector2;
  78599. /**
  78600. * Creates a new MultiLinePoint
  78601. * @param multiLine defines the source MultiLine object
  78602. */
  78603. constructor(multiLine: MultiLine);
  78604. /** Gets or sets x coordinate */
  78605. get x(): string | number;
  78606. set x(value: string | number);
  78607. /** Gets or sets y coordinate */
  78608. get y(): string | number;
  78609. set y(value: string | number);
  78610. /** Gets or sets the control associated with this point */
  78611. get control(): BABYLON.Nullable<Control>;
  78612. set control(value: BABYLON.Nullable<Control>);
  78613. /** Gets or sets the mesh associated with this point */
  78614. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78615. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78616. /** Resets links */
  78617. resetLinks(): void;
  78618. /**
  78619. * Gets a translation vector
  78620. * @returns the translation vector
  78621. */
  78622. translate(): BABYLON.Vector2;
  78623. private _translatePoint;
  78624. /** Release associated resources */
  78625. dispose(): void;
  78626. }
  78627. }
  78628. declare module BABYLON.GUI {
  78629. /**
  78630. * Class used to create multi line control
  78631. */
  78632. export class MultiLine extends Control {
  78633. name?: string | undefined;
  78634. private _lineWidth;
  78635. private _dash;
  78636. private _points;
  78637. private _minX;
  78638. private _minY;
  78639. private _maxX;
  78640. private _maxY;
  78641. /**
  78642. * Creates a new MultiLine
  78643. * @param name defines the control name
  78644. */
  78645. constructor(name?: string | undefined);
  78646. /** Gets or sets dash pattern */
  78647. get dash(): Array<number>;
  78648. set dash(value: Array<number>);
  78649. /**
  78650. * Gets point stored at specified index
  78651. * @param index defines the index to look for
  78652. * @returns the requested point if found
  78653. */
  78654. getAt(index: number): MultiLinePoint;
  78655. /** Function called when a point is updated */
  78656. onPointUpdate: () => void;
  78657. /**
  78658. * Adds new points to the point collection
  78659. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78660. * @returns the list of created MultiLinePoint
  78661. */
  78662. add(...items: (AbstractMesh | Control | {
  78663. x: string | number;
  78664. y: string | number;
  78665. })[]): MultiLinePoint[];
  78666. /**
  78667. * Adds a new point to the point collection
  78668. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78669. * @returns the created MultiLinePoint
  78670. */
  78671. push(item?: (AbstractMesh | Control | {
  78672. x: string | number;
  78673. y: string | number;
  78674. })): MultiLinePoint;
  78675. /**
  78676. * Remove a specific value or point from the active point collection
  78677. * @param value defines the value or point to remove
  78678. */
  78679. remove(value: number | MultiLinePoint): void;
  78680. /**
  78681. * Resets this object to initial state (no point)
  78682. */
  78683. reset(): void;
  78684. /**
  78685. * Resets all links
  78686. */
  78687. resetLinks(): void;
  78688. /** Gets or sets line width */
  78689. get lineWidth(): number;
  78690. set lineWidth(value: number);
  78691. set horizontalAlignment(value: number);
  78692. set verticalAlignment(value: number);
  78693. protected _getTypeName(): string;
  78694. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78695. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78696. _measure(): void;
  78697. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78698. dispose(): void;
  78699. }
  78700. }
  78701. declare module BABYLON.GUI {
  78702. /**
  78703. * Class used to create radio button controls
  78704. */
  78705. export class RadioButton extends Control {
  78706. name?: string | undefined;
  78707. private _isChecked;
  78708. private _background;
  78709. private _checkSizeRatio;
  78710. private _thickness;
  78711. /** Gets or sets border thickness */
  78712. get thickness(): number;
  78713. set thickness(value: number);
  78714. /** Gets or sets group name */
  78715. group: string;
  78716. /** BABYLON.Observable raised when isChecked is changed */
  78717. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78718. /** Gets or sets a value indicating the ratio between overall size and check size */
  78719. get checkSizeRatio(): number;
  78720. set checkSizeRatio(value: number);
  78721. /** Gets or sets background color */
  78722. get background(): string;
  78723. set background(value: string);
  78724. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78725. get isChecked(): boolean;
  78726. set isChecked(value: boolean);
  78727. /**
  78728. * Creates a new RadioButton
  78729. * @param name defines the control name
  78730. */
  78731. constructor(name?: string | undefined);
  78732. protected _getTypeName(): string;
  78733. _draw(context: CanvasRenderingContext2D): void;
  78734. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78735. /**
  78736. * Utility function to easily create a radio button with a header
  78737. * @param title defines the label to use for the header
  78738. * @param group defines the group to use for the radio button
  78739. * @param isChecked defines the initial state of the radio button
  78740. * @param onValueChanged defines the callback to call when value changes
  78741. * @returns a StackPanel containing the radio button and a textBlock
  78742. */
  78743. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78744. }
  78745. }
  78746. declare module BABYLON.GUI {
  78747. /**
  78748. * Class used to create slider controls
  78749. */
  78750. export class BaseSlider extends Control {
  78751. name?: string | undefined;
  78752. protected _thumbWidth: ValueAndUnit;
  78753. private _minimum;
  78754. private _maximum;
  78755. private _value;
  78756. private _isVertical;
  78757. protected _barOffset: ValueAndUnit;
  78758. private _isThumbClamped;
  78759. protected _displayThumb: boolean;
  78760. private _step;
  78761. private _lastPointerDownID;
  78762. protected _effectiveBarOffset: number;
  78763. protected _renderLeft: number;
  78764. protected _renderTop: number;
  78765. protected _renderWidth: number;
  78766. protected _renderHeight: number;
  78767. protected _backgroundBoxLength: number;
  78768. protected _backgroundBoxThickness: number;
  78769. protected _effectiveThumbThickness: number;
  78770. /** BABYLON.Observable raised when the sldier value changes */
  78771. onValueChangedObservable: BABYLON.Observable<number>;
  78772. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78773. get displayThumb(): boolean;
  78774. set displayThumb(value: boolean);
  78775. /** Gets or sets a step to apply to values (0 by default) */
  78776. get step(): number;
  78777. set step(value: number);
  78778. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78779. get barOffset(): string | number;
  78780. /** Gets main bar offset in pixels*/
  78781. get barOffsetInPixels(): number;
  78782. set barOffset(value: string | number);
  78783. /** Gets or sets thumb width */
  78784. get thumbWidth(): string | number;
  78785. /** Gets thumb width in pixels */
  78786. get thumbWidthInPixels(): number;
  78787. set thumbWidth(value: string | number);
  78788. /** Gets or sets minimum value */
  78789. get minimum(): number;
  78790. set minimum(value: number);
  78791. /** Gets or sets maximum value */
  78792. get maximum(): number;
  78793. set maximum(value: number);
  78794. /** Gets or sets current value */
  78795. get value(): number;
  78796. set value(value: number);
  78797. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78798. get isVertical(): boolean;
  78799. set isVertical(value: boolean);
  78800. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78801. get isThumbClamped(): boolean;
  78802. set isThumbClamped(value: boolean);
  78803. /**
  78804. * Creates a new BaseSlider
  78805. * @param name defines the control name
  78806. */
  78807. constructor(name?: string | undefined);
  78808. protected _getTypeName(): string;
  78809. protected _getThumbPosition(): number;
  78810. protected _getThumbThickness(type: string): number;
  78811. protected _prepareRenderingData(type: string): void;
  78812. private _pointerIsDown;
  78813. /** @hidden */
  78814. protected _updateValueFromPointer(x: number, y: number): void;
  78815. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78816. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78817. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78818. _onCanvasBlur(): void;
  78819. }
  78820. }
  78821. declare module BABYLON.GUI {
  78822. /**
  78823. * Class used to create slider controls
  78824. */
  78825. export class Slider extends BaseSlider {
  78826. name?: string | undefined;
  78827. private _background;
  78828. private _borderColor;
  78829. private _thumbColor;
  78830. private _isThumbCircle;
  78831. protected _displayValueBar: boolean;
  78832. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78833. get displayValueBar(): boolean;
  78834. set displayValueBar(value: boolean);
  78835. /** Gets or sets border color */
  78836. get borderColor(): string;
  78837. set borderColor(value: string);
  78838. /** Gets or sets background color */
  78839. get background(): string;
  78840. set background(value: string);
  78841. /** Gets or sets thumb's color */
  78842. get thumbColor(): string;
  78843. set thumbColor(value: string);
  78844. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78845. get isThumbCircle(): boolean;
  78846. set isThumbCircle(value: boolean);
  78847. /**
  78848. * Creates a new Slider
  78849. * @param name defines the control name
  78850. */
  78851. constructor(name?: string | undefined);
  78852. protected _getTypeName(): string;
  78853. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78854. }
  78855. }
  78856. declare module BABYLON.GUI {
  78857. /** Class used to create a RadioGroup
  78858. * which contains groups of radio buttons
  78859. */
  78860. export class SelectorGroup {
  78861. /** name of SelectorGroup */
  78862. name: string;
  78863. private _groupPanel;
  78864. private _selectors;
  78865. private _groupHeader;
  78866. /**
  78867. * Creates a new SelectorGroup
  78868. * @param name of group, used as a group heading
  78869. */
  78870. constructor(
  78871. /** name of SelectorGroup */
  78872. name: string);
  78873. /** Gets the groupPanel of the SelectorGroup */
  78874. get groupPanel(): StackPanel;
  78875. /** Gets the selectors array */
  78876. get selectors(): StackPanel[];
  78877. /** Gets and sets the group header */
  78878. get header(): string;
  78879. set header(label: string);
  78880. /** @hidden */
  78881. private _addGroupHeader;
  78882. /** @hidden*/
  78883. _getSelector(selectorNb: number): StackPanel | undefined;
  78884. /** Removes the selector at the given position
  78885. * @param selectorNb the position of the selector within the group
  78886. */
  78887. removeSelector(selectorNb: number): void;
  78888. }
  78889. /** Class used to create a CheckboxGroup
  78890. * which contains groups of checkbox buttons
  78891. */
  78892. export class CheckboxGroup extends SelectorGroup {
  78893. /** Adds a checkbox as a control
  78894. * @param text is the label for the selector
  78895. * @param func is the function called when the Selector is checked
  78896. * @param checked is true when Selector is checked
  78897. */
  78898. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78899. /** @hidden */
  78900. _setSelectorLabel(selectorNb: number, label: string): void;
  78901. /** @hidden */
  78902. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78903. /** @hidden */
  78904. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78905. /** @hidden */
  78906. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78907. }
  78908. /** Class used to create a RadioGroup
  78909. * which contains groups of radio buttons
  78910. */
  78911. export class RadioGroup extends SelectorGroup {
  78912. private _selectNb;
  78913. /** Adds a radio button as a control
  78914. * @param label is the label for the selector
  78915. * @param func is the function called when the Selector is checked
  78916. * @param checked is true when Selector is checked
  78917. */
  78918. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78919. /** @hidden */
  78920. _setSelectorLabel(selectorNb: number, label: string): void;
  78921. /** @hidden */
  78922. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78923. /** @hidden */
  78924. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78925. /** @hidden */
  78926. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78927. }
  78928. /** Class used to create a SliderGroup
  78929. * which contains groups of slider buttons
  78930. */
  78931. export class SliderGroup extends SelectorGroup {
  78932. /**
  78933. * Adds a slider to the SelectorGroup
  78934. * @param label is the label for the SliderBar
  78935. * @param func is the function called when the Slider moves
  78936. * @param unit is a string describing the units used, eg degrees or metres
  78937. * @param min is the minimum value for the Slider
  78938. * @param max is the maximum value for the Slider
  78939. * @param value is the start value for the Slider between min and max
  78940. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78941. */
  78942. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78943. /** @hidden */
  78944. _setSelectorLabel(selectorNb: number, label: string): void;
  78945. /** @hidden */
  78946. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78947. /** @hidden */
  78948. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78949. /** @hidden */
  78950. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78951. }
  78952. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78953. * @see https://doc.babylonjs.com/how_to/selector
  78954. */
  78955. export class SelectionPanel extends Rectangle {
  78956. /** name of SelectionPanel */
  78957. name: string;
  78958. /** an array of SelectionGroups */
  78959. groups: SelectorGroup[];
  78960. private _panel;
  78961. private _buttonColor;
  78962. private _buttonBackground;
  78963. private _headerColor;
  78964. private _barColor;
  78965. private _barHeight;
  78966. private _spacerHeight;
  78967. private _labelColor;
  78968. private _groups;
  78969. private _bars;
  78970. /**
  78971. * Creates a new SelectionPanel
  78972. * @param name of SelectionPanel
  78973. * @param groups is an array of SelectionGroups
  78974. */
  78975. constructor(
  78976. /** name of SelectionPanel */
  78977. name: string,
  78978. /** an array of SelectionGroups */
  78979. groups?: SelectorGroup[]);
  78980. protected _getTypeName(): string;
  78981. /** Gets or sets the headerColor */
  78982. get headerColor(): string;
  78983. set headerColor(color: string);
  78984. private _setHeaderColor;
  78985. /** Gets or sets the button color */
  78986. get buttonColor(): string;
  78987. set buttonColor(color: string);
  78988. private _setbuttonColor;
  78989. /** Gets or sets the label color */
  78990. get labelColor(): string;
  78991. set labelColor(color: string);
  78992. private _setLabelColor;
  78993. /** Gets or sets the button background */
  78994. get buttonBackground(): string;
  78995. set buttonBackground(color: string);
  78996. private _setButtonBackground;
  78997. /** Gets or sets the color of separator bar */
  78998. get barColor(): string;
  78999. set barColor(color: string);
  79000. private _setBarColor;
  79001. /** Gets or sets the height of separator bar */
  79002. get barHeight(): string;
  79003. set barHeight(value: string);
  79004. private _setBarHeight;
  79005. /** Gets or sets the height of spacers*/
  79006. get spacerHeight(): string;
  79007. set spacerHeight(value: string);
  79008. private _setSpacerHeight;
  79009. /** Adds a bar between groups */
  79010. private _addSpacer;
  79011. /** Add a group to the selection panel
  79012. * @param group is the selector group to add
  79013. */
  79014. addGroup(group: SelectorGroup): void;
  79015. /** Remove the group from the given position
  79016. * @param groupNb is the position of the group in the list
  79017. */
  79018. removeGroup(groupNb: number): void;
  79019. /** Change a group header label
  79020. * @param label is the new group header label
  79021. * @param groupNb is the number of the group to relabel
  79022. * */
  79023. setHeaderName(label: string, groupNb: number): void;
  79024. /** Change selector label to the one given
  79025. * @param label is the new selector label
  79026. * @param groupNb is the number of the groupcontaining the selector
  79027. * @param selectorNb is the number of the selector within a group to relabel
  79028. * */
  79029. relabel(label: string, groupNb: number, selectorNb: number): void;
  79030. /** For a given group position remove the selector at the given position
  79031. * @param groupNb is the number of the group to remove the selector from
  79032. * @param selectorNb is the number of the selector within the group
  79033. */
  79034. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79035. /** For a given group position of correct type add a checkbox button
  79036. * @param groupNb is the number of the group to remove the selector from
  79037. * @param label is the label for the selector
  79038. * @param func is the function called when the Selector is checked
  79039. * @param checked is true when Selector is checked
  79040. */
  79041. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79042. /** For a given group position of correct type add a radio button
  79043. * @param groupNb is the number of the group to remove the selector from
  79044. * @param label is the label for the selector
  79045. * @param func is the function called when the Selector is checked
  79046. * @param checked is true when Selector is checked
  79047. */
  79048. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79049. /**
  79050. * For a given slider group add a slider
  79051. * @param groupNb is the number of the group to add the slider to
  79052. * @param label is the label for the Slider
  79053. * @param func is the function called when the Slider moves
  79054. * @param unit is a string describing the units used, eg degrees or metres
  79055. * @param min is the minimum value for the Slider
  79056. * @param max is the maximum value for the Slider
  79057. * @param value is the start value for the Slider between min and max
  79058. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79059. */
  79060. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79061. }
  79062. }
  79063. declare module BABYLON.GUI {
  79064. /**
  79065. * Class used to hold a the container for ScrollViewer
  79066. * @hidden
  79067. */
  79068. export class _ScrollViewerWindow extends Container {
  79069. parentClientWidth: number;
  79070. parentClientHeight: number;
  79071. private _freezeControls;
  79072. private _parentMeasure;
  79073. private _oldLeft;
  79074. private _oldTop;
  79075. get freezeControls(): boolean;
  79076. set freezeControls(value: boolean);
  79077. private _bucketWidth;
  79078. private _bucketHeight;
  79079. private _buckets;
  79080. private _bucketLen;
  79081. get bucketWidth(): number;
  79082. get bucketHeight(): number;
  79083. setBucketSizes(width: number, height: number): void;
  79084. private _useBuckets;
  79085. private _makeBuckets;
  79086. private _dispatchInBuckets;
  79087. private _updateMeasures;
  79088. private _updateChildrenMeasures;
  79089. private _restoreMeasures;
  79090. /**
  79091. * Creates a new ScrollViewerWindow
  79092. * @param name of ScrollViewerWindow
  79093. */
  79094. constructor(name?: string);
  79095. protected _getTypeName(): string;
  79096. /** @hidden */
  79097. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79098. /** @hidden */
  79099. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79100. private _scrollChildren;
  79101. private _scrollChildrenWithBuckets;
  79102. /** @hidden */
  79103. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79104. protected _postMeasure(): void;
  79105. }
  79106. }
  79107. declare module BABYLON.GUI {
  79108. /**
  79109. * Class used to create slider controls
  79110. */
  79111. export class ScrollBar extends BaseSlider {
  79112. name?: string | undefined;
  79113. private _background;
  79114. private _borderColor;
  79115. private _tempMeasure;
  79116. /** Gets or sets border color */
  79117. get borderColor(): string;
  79118. set borderColor(value: string);
  79119. /** Gets or sets background color */
  79120. get background(): string;
  79121. set background(value: string);
  79122. /**
  79123. * Creates a new Slider
  79124. * @param name defines the control name
  79125. */
  79126. constructor(name?: string | undefined);
  79127. protected _getTypeName(): string;
  79128. protected _getThumbThickness(): number;
  79129. _draw(context: CanvasRenderingContext2D): void;
  79130. private _first;
  79131. private _originX;
  79132. private _originY;
  79133. /** @hidden */
  79134. protected _updateValueFromPointer(x: number, y: number): void;
  79135. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79136. }
  79137. }
  79138. declare module BABYLON.GUI {
  79139. /**
  79140. * Class used to create slider controls
  79141. */
  79142. export class ImageScrollBar extends BaseSlider {
  79143. name?: string | undefined;
  79144. private _backgroundBaseImage;
  79145. private _backgroundImage;
  79146. private _thumbImage;
  79147. private _thumbBaseImage;
  79148. private _thumbLength;
  79149. private _thumbHeight;
  79150. private _barImageHeight;
  79151. private _tempMeasure;
  79152. /** Number of 90° rotation to apply on the images when in vertical mode */
  79153. num90RotationInVerticalMode: number;
  79154. /**
  79155. * Gets or sets the image used to render the background for horizontal bar
  79156. */
  79157. get backgroundImage(): Image;
  79158. set backgroundImage(value: Image);
  79159. /**
  79160. * Gets or sets the image used to render the thumb
  79161. */
  79162. get thumbImage(): Image;
  79163. set thumbImage(value: Image);
  79164. /**
  79165. * Gets or sets the length of the thumb
  79166. */
  79167. get thumbLength(): number;
  79168. set thumbLength(value: number);
  79169. /**
  79170. * Gets or sets the height of the thumb
  79171. */
  79172. get thumbHeight(): number;
  79173. set thumbHeight(value: number);
  79174. /**
  79175. * Gets or sets the height of the bar image
  79176. */
  79177. get barImageHeight(): number;
  79178. set barImageHeight(value: number);
  79179. /**
  79180. * Creates a new ImageScrollBar
  79181. * @param name defines the control name
  79182. */
  79183. constructor(name?: string | undefined);
  79184. protected _getTypeName(): string;
  79185. protected _getThumbThickness(): number;
  79186. _draw(context: CanvasRenderingContext2D): void;
  79187. private _first;
  79188. private _originX;
  79189. private _originY;
  79190. /** @hidden */
  79191. protected _updateValueFromPointer(x: number, y: number): void;
  79192. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79193. }
  79194. }
  79195. declare module BABYLON.GUI {
  79196. /**
  79197. * Class used to hold a viewer window and sliders in a grid
  79198. */
  79199. export class ScrollViewer extends Rectangle {
  79200. private _grid;
  79201. private _horizontalBarSpace;
  79202. private _verticalBarSpace;
  79203. private _dragSpace;
  79204. private _horizontalBar;
  79205. private _verticalBar;
  79206. private _barColor;
  79207. private _barBackground;
  79208. private _barImage;
  79209. private _horizontalBarImage;
  79210. private _verticalBarImage;
  79211. private _barBackgroundImage;
  79212. private _horizontalBarBackgroundImage;
  79213. private _verticalBarBackgroundImage;
  79214. private _barSize;
  79215. private _window;
  79216. private _pointerIsOver;
  79217. private _wheelPrecision;
  79218. private _onWheelObserver;
  79219. private _clientWidth;
  79220. private _clientHeight;
  79221. private _useImageBar;
  79222. private _thumbLength;
  79223. private _thumbHeight;
  79224. private _barImageHeight;
  79225. private _horizontalBarImageHeight;
  79226. private _verticalBarImageHeight;
  79227. private _oldWindowContentsWidth;
  79228. private _oldWindowContentsHeight;
  79229. /**
  79230. * Gets the horizontal scrollbar
  79231. */
  79232. get horizontalBar(): ScrollBar | ImageScrollBar;
  79233. /**
  79234. * Gets the vertical scrollbar
  79235. */
  79236. get verticalBar(): ScrollBar | ImageScrollBar;
  79237. /**
  79238. * Adds a new control to the current container
  79239. * @param control defines the control to add
  79240. * @returns the current container
  79241. */
  79242. addControl(control: BABYLON.Nullable<Control>): Container;
  79243. /**
  79244. * Removes a control from the current container
  79245. * @param control defines the control to remove
  79246. * @returns the current container
  79247. */
  79248. removeControl(control: Control): Container;
  79249. /** Gets the list of children */
  79250. get children(): Control[];
  79251. _flagDescendantsAsMatrixDirty(): void;
  79252. /**
  79253. * Freezes or unfreezes the controls in the window.
  79254. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79255. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79256. */
  79257. get freezeControls(): boolean;
  79258. set freezeControls(value: boolean);
  79259. /** Gets the bucket width */
  79260. get bucketWidth(): number;
  79261. /** Gets the bucket height */
  79262. get bucketHeight(): number;
  79263. /**
  79264. * Sets the bucket sizes.
  79265. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79266. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79267. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79268. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79269. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79270. * used), that's why it is not enabled by default.
  79271. * @param width width of the bucket
  79272. * @param height height of the bucket
  79273. */
  79274. setBucketSizes(width: number, height: number): void;
  79275. private _forceHorizontalBar;
  79276. private _forceVerticalBar;
  79277. /**
  79278. * Forces the horizontal scroll bar to be displayed
  79279. */
  79280. get forceHorizontalBar(): boolean;
  79281. set forceHorizontalBar(value: boolean);
  79282. /**
  79283. * Forces the vertical scroll bar to be displayed
  79284. */
  79285. get forceVerticalBar(): boolean;
  79286. set forceVerticalBar(value: boolean);
  79287. /**
  79288. * Creates a new ScrollViewer
  79289. * @param name of ScrollViewer
  79290. */
  79291. constructor(name?: string, isImageBased?: boolean);
  79292. /** Reset the scroll viewer window to initial size */
  79293. resetWindow(): void;
  79294. protected _getTypeName(): string;
  79295. private _buildClientSizes;
  79296. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79297. protected _postMeasure(): void;
  79298. /**
  79299. * Gets or sets the mouse wheel precision
  79300. * from 0 to 1 with a default value of 0.05
  79301. * */
  79302. get wheelPrecision(): number;
  79303. set wheelPrecision(value: number);
  79304. /** Gets or sets the scroll bar container background color */
  79305. get scrollBackground(): string;
  79306. set scrollBackground(color: string);
  79307. /** Gets or sets the bar color */
  79308. get barColor(): string;
  79309. set barColor(color: string);
  79310. /** Gets or sets the bar image */
  79311. get thumbImage(): Image;
  79312. set thumbImage(value: Image);
  79313. /** Gets or sets the horizontal bar image */
  79314. get horizontalThumbImage(): Image;
  79315. set horizontalThumbImage(value: Image);
  79316. /** Gets or sets the vertical bar image */
  79317. get verticalThumbImage(): Image;
  79318. set verticalThumbImage(value: Image);
  79319. /** Gets or sets the size of the bar */
  79320. get barSize(): number;
  79321. set barSize(value: number);
  79322. /** Gets or sets the length of the thumb */
  79323. get thumbLength(): number;
  79324. set thumbLength(value: number);
  79325. /** Gets or sets the height of the thumb */
  79326. get thumbHeight(): number;
  79327. set thumbHeight(value: number);
  79328. /** Gets or sets the height of the bar image */
  79329. get barImageHeight(): number;
  79330. set barImageHeight(value: number);
  79331. /** Gets or sets the height of the horizontal bar image */
  79332. get horizontalBarImageHeight(): number;
  79333. set horizontalBarImageHeight(value: number);
  79334. /** Gets or sets the height of the vertical bar image */
  79335. get verticalBarImageHeight(): number;
  79336. set verticalBarImageHeight(value: number);
  79337. /** Gets or sets the bar background */
  79338. get barBackground(): string;
  79339. set barBackground(color: string);
  79340. /** Gets or sets the bar background image */
  79341. get barImage(): Image;
  79342. set barImage(value: Image);
  79343. /** Gets or sets the horizontal bar background image */
  79344. get horizontalBarImage(): Image;
  79345. set horizontalBarImage(value: Image);
  79346. /** Gets or sets the vertical bar background image */
  79347. get verticalBarImage(): Image;
  79348. set verticalBarImage(value: Image);
  79349. private _setWindowPosition;
  79350. /** @hidden */
  79351. private _updateScroller;
  79352. _link(host: AdvancedDynamicTexture): void;
  79353. /** @hidden */
  79354. private _addBar;
  79355. /** @hidden */
  79356. private _attachWheel;
  79357. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79358. /** Releases associated resources */
  79359. dispose(): void;
  79360. }
  79361. }
  79362. declare module BABYLON.GUI {
  79363. /** Class used to render a grid */
  79364. export class DisplayGrid extends Control {
  79365. name?: string | undefined;
  79366. private _cellWidth;
  79367. private _cellHeight;
  79368. private _minorLineTickness;
  79369. private _minorLineColor;
  79370. private _majorLineTickness;
  79371. private _majorLineColor;
  79372. private _majorLineFrequency;
  79373. private _background;
  79374. private _displayMajorLines;
  79375. private _displayMinorLines;
  79376. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79377. get displayMinorLines(): boolean;
  79378. set displayMinorLines(value: boolean);
  79379. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79380. get displayMajorLines(): boolean;
  79381. set displayMajorLines(value: boolean);
  79382. /** Gets or sets background color (Black by default) */
  79383. get background(): string;
  79384. set background(value: string);
  79385. /** Gets or sets the width of each cell (20 by default) */
  79386. get cellWidth(): number;
  79387. set cellWidth(value: number);
  79388. /** Gets or sets the height of each cell (20 by default) */
  79389. get cellHeight(): number;
  79390. set cellHeight(value: number);
  79391. /** Gets or sets the tickness of minor lines (1 by default) */
  79392. get minorLineTickness(): number;
  79393. set minorLineTickness(value: number);
  79394. /** Gets or sets the color of minor lines (DarkGray by default) */
  79395. get minorLineColor(): string;
  79396. set minorLineColor(value: string);
  79397. /** Gets or sets the tickness of major lines (2 by default) */
  79398. get majorLineTickness(): number;
  79399. set majorLineTickness(value: number);
  79400. /** Gets or sets the color of major lines (White by default) */
  79401. get majorLineColor(): string;
  79402. set majorLineColor(value: string);
  79403. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79404. get majorLineFrequency(): number;
  79405. set majorLineFrequency(value: number);
  79406. /**
  79407. * Creates a new GridDisplayRectangle
  79408. * @param name defines the control name
  79409. */
  79410. constructor(name?: string | undefined);
  79411. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79412. protected _getTypeName(): string;
  79413. }
  79414. }
  79415. declare module BABYLON.GUI {
  79416. /**
  79417. * Class used to create slider controls based on images
  79418. */
  79419. export class ImageBasedSlider extends BaseSlider {
  79420. name?: string | undefined;
  79421. private _backgroundImage;
  79422. private _thumbImage;
  79423. private _valueBarImage;
  79424. private _tempMeasure;
  79425. get displayThumb(): boolean;
  79426. set displayThumb(value: boolean);
  79427. /**
  79428. * Gets or sets the image used to render the background
  79429. */
  79430. get backgroundImage(): Image;
  79431. set backgroundImage(value: Image);
  79432. /**
  79433. * Gets or sets the image used to render the value bar
  79434. */
  79435. get valueBarImage(): Image;
  79436. set valueBarImage(value: Image);
  79437. /**
  79438. * Gets or sets the image used to render the thumb
  79439. */
  79440. get thumbImage(): Image;
  79441. set thumbImage(value: Image);
  79442. /**
  79443. * Creates a new ImageBasedSlider
  79444. * @param name defines the control name
  79445. */
  79446. constructor(name?: string | undefined);
  79447. protected _getTypeName(): string;
  79448. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79449. }
  79450. }
  79451. declare module BABYLON.GUI {
  79452. /**
  79453. * Forcing an export so that this code will execute
  79454. * @hidden
  79455. */
  79456. const name = "Statics";
  79457. }
  79458. declare module BABYLON.GUI {
  79459. /**
  79460. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79461. */
  79462. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79463. /**
  79464. * Define the instrumented AdvancedDynamicTexture.
  79465. */
  79466. texture: AdvancedDynamicTexture;
  79467. private _captureRenderTime;
  79468. private _renderTime;
  79469. private _captureLayoutTime;
  79470. private _layoutTime;
  79471. private _onBeginRenderObserver;
  79472. private _onEndRenderObserver;
  79473. private _onBeginLayoutObserver;
  79474. private _onEndLayoutObserver;
  79475. /**
  79476. * Gets the perf counter used to capture render time
  79477. */
  79478. get renderTimeCounter(): BABYLON.PerfCounter;
  79479. /**
  79480. * Gets the perf counter used to capture layout time
  79481. */
  79482. get layoutTimeCounter(): BABYLON.PerfCounter;
  79483. /**
  79484. * Enable or disable the render time capture
  79485. */
  79486. get captureRenderTime(): boolean;
  79487. set captureRenderTime(value: boolean);
  79488. /**
  79489. * Enable or disable the layout time capture
  79490. */
  79491. get captureLayoutTime(): boolean;
  79492. set captureLayoutTime(value: boolean);
  79493. /**
  79494. * Instantiates a new advanced dynamic texture instrumentation.
  79495. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79496. * @param texture Defines the AdvancedDynamicTexture to instrument
  79497. */
  79498. constructor(
  79499. /**
  79500. * Define the instrumented AdvancedDynamicTexture.
  79501. */
  79502. texture: AdvancedDynamicTexture);
  79503. /**
  79504. * Dispose and release associated resources.
  79505. */
  79506. dispose(): void;
  79507. }
  79508. }
  79509. declare module BABYLON.GUI {
  79510. /**
  79511. * Class used to load GUI via XML.
  79512. */
  79513. export class XmlLoader {
  79514. private _nodes;
  79515. private _nodeTypes;
  79516. private _isLoaded;
  79517. private _objectAttributes;
  79518. private _parentClass;
  79519. /**
  79520. * Create a new xml loader
  79521. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79522. */
  79523. constructor(parentClass?: null);
  79524. private _getChainElement;
  79525. private _getClassAttribute;
  79526. private _createGuiElement;
  79527. private _parseGrid;
  79528. private _parseElement;
  79529. private _prepareSourceElement;
  79530. private _parseElementsFromSource;
  79531. private _parseXml;
  79532. /**
  79533. * Gets if the loading has finished.
  79534. * @returns whether the loading has finished or not
  79535. */
  79536. isLoaded(): boolean;
  79537. /**
  79538. * Gets a loaded node / control by id.
  79539. * @param id the Controls id set in the xml
  79540. * @returns element of type Control
  79541. */
  79542. getNodeById(id: string): any;
  79543. /**
  79544. * Gets all loaded nodes / controls
  79545. * @returns Array of controls
  79546. */
  79547. getNodes(): any;
  79548. /**
  79549. * Initiates the xml layout loading
  79550. * @param xmlFile defines the xml layout to load
  79551. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79552. * @param callback defines the callback called on layout load.
  79553. */
  79554. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79555. }
  79556. }
  79557. declare module BABYLON.GUI {
  79558. /**
  79559. * Class used to create containers for controls
  79560. */
  79561. export class Container3D extends Control3D {
  79562. private _blockLayout;
  79563. /**
  79564. * Gets the list of child controls
  79565. */
  79566. protected _children: Control3D[];
  79567. /**
  79568. * Gets the list of child controls
  79569. */
  79570. get children(): Array<Control3D>;
  79571. /**
  79572. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79573. * This is helpful to optimize layout operation when adding multiple children in a row
  79574. */
  79575. get blockLayout(): boolean;
  79576. set blockLayout(value: boolean);
  79577. /**
  79578. * Creates a new container
  79579. * @param name defines the container name
  79580. */
  79581. constructor(name?: string);
  79582. /**
  79583. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79584. * @returns the current container
  79585. */
  79586. updateLayout(): Container3D;
  79587. /**
  79588. * Gets a boolean indicating if the given control is in the children of this control
  79589. * @param control defines the control to check
  79590. * @returns true if the control is in the child list
  79591. */
  79592. containsControl(control: Control3D): boolean;
  79593. /**
  79594. * Adds a control to the children of this control
  79595. * @param control defines the control to add
  79596. * @returns the current container
  79597. */
  79598. addControl(control: Control3D): Container3D;
  79599. /**
  79600. * This function will be called everytime a new control is added
  79601. */
  79602. protected _arrangeChildren(): void;
  79603. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79604. /**
  79605. * Removes a control from the children of this control
  79606. * @param control defines the control to remove
  79607. * @returns the current container
  79608. */
  79609. removeControl(control: Control3D): Container3D;
  79610. protected _getTypeName(): string;
  79611. /**
  79612. * Releases all associated resources
  79613. */
  79614. dispose(): void;
  79615. /** Control rotation will remain unchanged */
  79616. static readonly UNSET_ORIENTATION: number;
  79617. /** Control will rotate to make it look at sphere central axis */
  79618. static readonly FACEORIGIN_ORIENTATION: number;
  79619. /** Control will rotate to make it look back at sphere central axis */
  79620. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79621. /** Control will rotate to look at z axis (0, 0, 1) */
  79622. static readonly FACEFORWARD_ORIENTATION: number;
  79623. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79624. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79625. }
  79626. }
  79627. declare module BABYLON.GUI {
  79628. /**
  79629. * Class used to manage 3D user interface
  79630. * @see https://doc.babylonjs.com/how_to/gui3d
  79631. */
  79632. export class GUI3DManager implements BABYLON.IDisposable {
  79633. private _scene;
  79634. private _sceneDisposeObserver;
  79635. private _utilityLayer;
  79636. private _rootContainer;
  79637. private _pointerObserver;
  79638. private _pointerOutObserver;
  79639. /** @hidden */
  79640. _lastPickedControl: Control3D;
  79641. /** @hidden */
  79642. _lastControlOver: {
  79643. [pointerId: number]: Control3D;
  79644. };
  79645. /** @hidden */
  79646. _lastControlDown: {
  79647. [pointerId: number]: Control3D;
  79648. };
  79649. /**
  79650. * BABYLON.Observable raised when the point picked by the pointer events changed
  79651. */
  79652. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79653. /** @hidden */
  79654. _sharedMaterials: {
  79655. [key: string]: BABYLON.Material;
  79656. };
  79657. /** Gets the hosting scene */
  79658. get scene(): BABYLON.Scene;
  79659. /** Gets associated utility layer */
  79660. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79661. /**
  79662. * Creates a new GUI3DManager
  79663. * @param scene
  79664. */
  79665. constructor(scene?: BABYLON.Scene);
  79666. private _handlePointerOut;
  79667. private _doPicking;
  79668. /**
  79669. * Gets the root container
  79670. */
  79671. get rootContainer(): Container3D;
  79672. /**
  79673. * Gets a boolean indicating if the given control is in the root child list
  79674. * @param control defines the control to check
  79675. * @returns true if the control is in the root child list
  79676. */
  79677. containsControl(control: Control3D): boolean;
  79678. /**
  79679. * Adds a control to the root child list
  79680. * @param control defines the control to add
  79681. * @returns the current manager
  79682. */
  79683. addControl(control: Control3D): GUI3DManager;
  79684. /**
  79685. * Removes a control from the root child list
  79686. * @param control defines the control to remove
  79687. * @returns the current container
  79688. */
  79689. removeControl(control: Control3D): GUI3DManager;
  79690. /**
  79691. * Releases all associated resources
  79692. */
  79693. dispose(): void;
  79694. }
  79695. }
  79696. declare module BABYLON.GUI {
  79697. /**
  79698. * Class used to transport BABYLON.Vector3 information for pointer events
  79699. */
  79700. export class Vector3WithInfo extends BABYLON.Vector3 {
  79701. /** defines the current mouse button index */
  79702. buttonIndex: number;
  79703. /**
  79704. * Creates a new Vector3WithInfo
  79705. * @param source defines the vector3 data to transport
  79706. * @param buttonIndex defines the current mouse button index
  79707. */
  79708. constructor(source: BABYLON.Vector3,
  79709. /** defines the current mouse button index */
  79710. buttonIndex?: number);
  79711. }
  79712. }
  79713. declare module BABYLON.GUI {
  79714. /**
  79715. * Class used as base class for controls
  79716. */
  79717. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79718. /** Defines the control name */
  79719. name?: string | undefined;
  79720. /** @hidden */
  79721. _host: GUI3DManager;
  79722. private _node;
  79723. private _downCount;
  79724. private _enterCount;
  79725. private _downPointerIds;
  79726. private _isVisible;
  79727. /** Gets or sets the control position in world space */
  79728. get position(): BABYLON.Vector3;
  79729. set position(value: BABYLON.Vector3);
  79730. /** Gets or sets the control scaling in world space */
  79731. get scaling(): BABYLON.Vector3;
  79732. set scaling(value: BABYLON.Vector3);
  79733. /** Callback used to start pointer enter animation */
  79734. pointerEnterAnimation: () => void;
  79735. /** Callback used to start pointer out animation */
  79736. pointerOutAnimation: () => void;
  79737. /** Callback used to start pointer down animation */
  79738. pointerDownAnimation: () => void;
  79739. /** Callback used to start pointer up animation */
  79740. pointerUpAnimation: () => void;
  79741. /**
  79742. * An event triggered when the pointer move over the control
  79743. */
  79744. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79745. /**
  79746. * An event triggered when the pointer move out of the control
  79747. */
  79748. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79749. /**
  79750. * An event triggered when the pointer taps the control
  79751. */
  79752. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79753. /**
  79754. * An event triggered when pointer is up
  79755. */
  79756. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79757. /**
  79758. * An event triggered when a control is clicked on (with a mouse)
  79759. */
  79760. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79761. /**
  79762. * An event triggered when pointer enters the control
  79763. */
  79764. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79765. /**
  79766. * Gets or sets the parent container
  79767. */
  79768. parent: BABYLON.Nullable<Container3D>;
  79769. private _behaviors;
  79770. /**
  79771. * Gets the list of attached behaviors
  79772. * @see https://doc.babylonjs.com/features/behaviour
  79773. */
  79774. get behaviors(): BABYLON.Behavior<Control3D>[];
  79775. /**
  79776. * Attach a behavior to the control
  79777. * @see https://doc.babylonjs.com/features/behaviour
  79778. * @param behavior defines the behavior to attach
  79779. * @returns the current control
  79780. */
  79781. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79782. /**
  79783. * Remove an attached behavior
  79784. * @see https://doc.babylonjs.com/features/behaviour
  79785. * @param behavior defines the behavior to attach
  79786. * @returns the current control
  79787. */
  79788. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79789. /**
  79790. * Gets an attached behavior by name
  79791. * @param name defines the name of the behavior to look for
  79792. * @see https://doc.babylonjs.com/features/behaviour
  79793. * @returns null if behavior was not found else the requested behavior
  79794. */
  79795. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79796. /** Gets or sets a boolean indicating if the control is visible */
  79797. get isVisible(): boolean;
  79798. set isVisible(value: boolean);
  79799. /**
  79800. * Creates a new control
  79801. * @param name defines the control name
  79802. */
  79803. constructor(
  79804. /** Defines the control name */
  79805. name?: string | undefined);
  79806. /**
  79807. * Gets a string representing the class name
  79808. */
  79809. get typeName(): string;
  79810. /**
  79811. * Get the current class name of the control.
  79812. * @returns current class name
  79813. */
  79814. getClassName(): string;
  79815. protected _getTypeName(): string;
  79816. /**
  79817. * Gets the transform node used by this control
  79818. */
  79819. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79820. /**
  79821. * Gets the mesh used to render this control
  79822. */
  79823. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79824. /**
  79825. * Link the control as child of the given node
  79826. * @param node defines the node to link to. Use null to unlink the control
  79827. * @returns the current control
  79828. */
  79829. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79830. /** @hidden **/
  79831. _prepareNode(scene: BABYLON.Scene): void;
  79832. /**
  79833. * Node creation.
  79834. * Can be overriden by children
  79835. * @param scene defines the scene where the node must be attached
  79836. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79837. */
  79838. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79839. /**
  79840. * Affect a material to the given mesh
  79841. * @param mesh defines the mesh which will represent the control
  79842. */
  79843. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79844. /** @hidden */
  79845. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79846. /** @hidden */
  79847. _onPointerEnter(target: Control3D): boolean;
  79848. /** @hidden */
  79849. _onPointerOut(target: Control3D): void;
  79850. /** @hidden */
  79851. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79852. /** @hidden */
  79853. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79854. /** @hidden */
  79855. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79856. /** @hidden */
  79857. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79858. /** @hidden */
  79859. _disposeNode(): void;
  79860. /**
  79861. * Releases all associated resources
  79862. */
  79863. dispose(): void;
  79864. }
  79865. }
  79866. declare module BABYLON.GUI {
  79867. /**
  79868. * Class used as a root to all buttons
  79869. */
  79870. export class AbstractButton3D extends Control3D {
  79871. /**
  79872. * Creates a new button
  79873. * @param name defines the control name
  79874. */
  79875. constructor(name?: string);
  79876. protected _getTypeName(): string;
  79877. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79878. }
  79879. }
  79880. declare module BABYLON.GUI {
  79881. /**
  79882. * Class used to create a button in 3D
  79883. */
  79884. export class Button3D extends AbstractButton3D {
  79885. /** @hidden */
  79886. protected _currentMaterial: BABYLON.Material;
  79887. private _facadeTexture;
  79888. private _content;
  79889. private _contentResolution;
  79890. private _contentScaleRatio;
  79891. /**
  79892. * Gets or sets the texture resolution used to render content (512 by default)
  79893. */
  79894. get contentResolution(): BABYLON.int;
  79895. set contentResolution(value: BABYLON.int);
  79896. /**
  79897. * Gets or sets the texture scale ratio used to render content (2 by default)
  79898. */
  79899. get contentScaleRatio(): number;
  79900. set contentScaleRatio(value: number);
  79901. protected _disposeFacadeTexture(): void;
  79902. protected _resetContent(): void;
  79903. /**
  79904. * Creates a new button
  79905. * @param name defines the control name
  79906. */
  79907. constructor(name?: string);
  79908. /**
  79909. * Gets or sets the GUI 2D content used to display the button's facade
  79910. */
  79911. get content(): Control;
  79912. set content(value: Control);
  79913. /**
  79914. * Apply the facade texture (created from the content property).
  79915. * This function can be overloaded by child classes
  79916. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79917. */
  79918. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79919. protected _getTypeName(): string;
  79920. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79921. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79922. /**
  79923. * Releases all associated resources
  79924. */
  79925. dispose(): void;
  79926. }
  79927. }
  79928. declare module BABYLON.GUI {
  79929. /**
  79930. * Abstract class used to create a container panel deployed on the surface of a volume
  79931. */
  79932. export abstract class VolumeBasedPanel extends Container3D {
  79933. private _columns;
  79934. private _rows;
  79935. private _rowThenColum;
  79936. private _orientation;
  79937. protected _cellWidth: number;
  79938. protected _cellHeight: number;
  79939. /**
  79940. * Gets or sets the distance between elements
  79941. */
  79942. margin: number;
  79943. /**
  79944. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79945. * | Value | Type | Description |
  79946. * | ----- | ----------------------------------- | ----------- |
  79947. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79948. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79949. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79950. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79951. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79952. */
  79953. get orientation(): number;
  79954. set orientation(value: number);
  79955. /**
  79956. * Gets or sets the number of columns requested (10 by default).
  79957. * The panel will automatically compute the number of rows based on number of child controls.
  79958. */
  79959. get columns(): BABYLON.int;
  79960. set columns(value: BABYLON.int);
  79961. /**
  79962. * Gets or sets a the number of rows requested.
  79963. * The panel will automatically compute the number of columns based on number of child controls.
  79964. */
  79965. get rows(): BABYLON.int;
  79966. set rows(value: BABYLON.int);
  79967. /**
  79968. * Creates new VolumeBasedPanel
  79969. */
  79970. constructor();
  79971. protected _arrangeChildren(): void;
  79972. /** Child classes must implement this function to provide correct control positioning */
  79973. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79974. /** Child classes can implement this function to provide additional processing */
  79975. protected _finalProcessing(): void;
  79976. }
  79977. }
  79978. declare module BABYLON.GUI {
  79979. /**
  79980. * Class used to create a container panel deployed on the surface of a cylinder
  79981. */
  79982. export class CylinderPanel extends VolumeBasedPanel {
  79983. private _radius;
  79984. /**
  79985. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79986. */
  79987. get radius(): BABYLON.float;
  79988. set radius(value: BABYLON.float);
  79989. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79990. private _cylindricalMapping;
  79991. }
  79992. }
  79993. declare module BABYLON.GUI {
  79994. /** @hidden */
  79995. export var fluentVertexShader: {
  79996. name: string;
  79997. shader: string;
  79998. };
  79999. }
  80000. declare module BABYLON.GUI {
  80001. /** @hidden */
  80002. export var fluentPixelShader: {
  80003. name: string;
  80004. shader: string;
  80005. };
  80006. }
  80007. declare module BABYLON.GUI {
  80008. /** @hidden */
  80009. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80010. INNERGLOW: boolean;
  80011. BORDER: boolean;
  80012. HOVERLIGHT: boolean;
  80013. TEXTURE: boolean;
  80014. constructor();
  80015. }
  80016. /**
  80017. * Class used to render controls with fluent desgin
  80018. */
  80019. export class FluentMaterial extends BABYLON.PushMaterial {
  80020. /**
  80021. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80022. */
  80023. innerGlowColorIntensity: number;
  80024. /**
  80025. * Gets or sets the inner glow color (white by default)
  80026. */
  80027. innerGlowColor: BABYLON.Color3;
  80028. /**
  80029. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80030. */
  80031. albedoColor: BABYLON.Color3;
  80032. /**
  80033. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80034. */
  80035. renderBorders: boolean;
  80036. /**
  80037. * Gets or sets border width (default is 0.5)
  80038. */
  80039. borderWidth: number;
  80040. /**
  80041. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80042. */
  80043. edgeSmoothingValue: number;
  80044. /**
  80045. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80046. */
  80047. borderMinValue: number;
  80048. /**
  80049. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80050. */
  80051. renderHoverLight: boolean;
  80052. /**
  80053. * Gets or sets the radius used to render the hover light (default is 1.0)
  80054. */
  80055. hoverRadius: number;
  80056. /**
  80057. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80058. */
  80059. hoverColor: BABYLON.Color4;
  80060. /**
  80061. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80062. */
  80063. hoverPosition: BABYLON.Vector3;
  80064. private _albedoTexture;
  80065. /** Gets or sets the texture to use for albedo color */
  80066. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80067. /**
  80068. * Creates a new Fluent material
  80069. * @param name defines the name of the material
  80070. * @param scene defines the hosting scene
  80071. */
  80072. constructor(name: string, scene: BABYLON.Scene);
  80073. needAlphaBlending(): boolean;
  80074. needAlphaTesting(): boolean;
  80075. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80076. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80077. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80078. getActiveTextures(): BABYLON.BaseTexture[];
  80079. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80080. dispose(forceDisposeEffect?: boolean): void;
  80081. clone(name: string): FluentMaterial;
  80082. serialize(): any;
  80083. getClassName(): string;
  80084. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80085. }
  80086. }
  80087. declare module BABYLON.GUI {
  80088. /**
  80089. * Class used to create a holographic button in 3D
  80090. */
  80091. export class HolographicButton extends Button3D {
  80092. private _backPlate;
  80093. private _textPlate;
  80094. private _frontPlate;
  80095. private _text;
  80096. private _imageUrl;
  80097. private _shareMaterials;
  80098. private _frontMaterial;
  80099. private _backMaterial;
  80100. private _plateMaterial;
  80101. private _pickedPointObserver;
  80102. private _tooltipFade;
  80103. private _tooltipTextBlock;
  80104. private _tooltipTexture;
  80105. private _tooltipMesh;
  80106. private _tooltipHoverObserver;
  80107. private _tooltipOutObserver;
  80108. private _disposeTooltip;
  80109. /**
  80110. * Rendering ground id of all the mesh in the button
  80111. */
  80112. set renderingGroupId(id: number);
  80113. get renderingGroupId(): number;
  80114. /**
  80115. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80116. */
  80117. set tooltipText(text: BABYLON.Nullable<string>);
  80118. get tooltipText(): BABYLON.Nullable<string>;
  80119. /**
  80120. * Gets or sets text for the button
  80121. */
  80122. get text(): string;
  80123. set text(value: string);
  80124. /**
  80125. * Gets or sets the image url for the button
  80126. */
  80127. get imageUrl(): string;
  80128. set imageUrl(value: string);
  80129. /**
  80130. * Gets the back material used by this button
  80131. */
  80132. get backMaterial(): FluentMaterial;
  80133. /**
  80134. * Gets the front material used by this button
  80135. */
  80136. get frontMaterial(): FluentMaterial;
  80137. /**
  80138. * Gets the plate material used by this button
  80139. */
  80140. get plateMaterial(): BABYLON.StandardMaterial;
  80141. /**
  80142. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80143. */
  80144. get shareMaterials(): boolean;
  80145. /**
  80146. * Creates a new button
  80147. * @param name defines the control name
  80148. */
  80149. constructor(name?: string, shareMaterials?: boolean);
  80150. protected _getTypeName(): string;
  80151. private _rebuildContent;
  80152. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80153. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80154. private _createBackMaterial;
  80155. private _createFrontMaterial;
  80156. private _createPlateMaterial;
  80157. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80158. /**
  80159. * Releases all associated resources
  80160. */
  80161. dispose(): void;
  80162. }
  80163. }
  80164. declare module BABYLON.GUI {
  80165. /**
  80166. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80167. */
  80168. export class MeshButton3D extends Button3D {
  80169. /** @hidden */
  80170. protected _currentMesh: BABYLON.Mesh;
  80171. /**
  80172. * Creates a new 3D button based on a mesh
  80173. * @param mesh mesh to become a 3D button
  80174. * @param name defines the control name
  80175. */
  80176. constructor(mesh: BABYLON.Mesh, name?: string);
  80177. protected _getTypeName(): string;
  80178. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80179. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80180. }
  80181. }
  80182. declare module BABYLON.GUI {
  80183. /**
  80184. * Class used to create a container panel deployed on the surface of a plane
  80185. */
  80186. export class PlanePanel extends VolumeBasedPanel {
  80187. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80188. }
  80189. }
  80190. declare module BABYLON.GUI {
  80191. /**
  80192. * Class used to create a container panel where items get randomized planar mapping
  80193. */
  80194. export class ScatterPanel extends VolumeBasedPanel {
  80195. private _iteration;
  80196. /**
  80197. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80198. */
  80199. get iteration(): BABYLON.float;
  80200. set iteration(value: BABYLON.float);
  80201. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80202. private _scatterMapping;
  80203. protected _finalProcessing(): void;
  80204. }
  80205. }
  80206. declare module BABYLON.GUI {
  80207. /**
  80208. * Class used to create a container panel deployed on the surface of a sphere
  80209. */
  80210. export class SpherePanel extends VolumeBasedPanel {
  80211. private _radius;
  80212. /**
  80213. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80214. */
  80215. get radius(): BABYLON.float;
  80216. set radius(value: BABYLON.float);
  80217. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80218. private _sphericalMapping;
  80219. }
  80220. }
  80221. declare module BABYLON.GUI {
  80222. /**
  80223. * Class used to create a stack panel in 3D on XY plane
  80224. */
  80225. export class StackPanel3D extends Container3D {
  80226. private _isVertical;
  80227. /**
  80228. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80229. */
  80230. get isVertical(): boolean;
  80231. set isVertical(value: boolean);
  80232. /**
  80233. * Gets or sets the distance between elements
  80234. */
  80235. margin: number;
  80236. /**
  80237. * Creates new StackPanel
  80238. * @param isVertical
  80239. */
  80240. constructor(isVertical?: boolean);
  80241. protected _arrangeChildren(): void;
  80242. }
  80243. }
  80244. declare module BABYLON {
  80245. /**
  80246. * Configuration for glTF validation
  80247. */
  80248. export interface IGLTFValidationConfiguration {
  80249. /**
  80250. * The url of the glTF validator.
  80251. */
  80252. url: string;
  80253. }
  80254. /**
  80255. * glTF validation
  80256. */
  80257. export class GLTFValidation {
  80258. /**
  80259. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80260. */
  80261. static Configuration: IGLTFValidationConfiguration;
  80262. private static _LoadScriptPromise;
  80263. /**
  80264. * Validate a glTF asset using the glTF-Validator.
  80265. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80266. * @param rootUrl The root url for the glTF
  80267. * @param fileName The file name for the glTF
  80268. * @param getExternalResource The callback to get external resources for the glTF validator
  80269. * @returns A promise that resolves with the glTF validation results once complete
  80270. */
  80271. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80272. }
  80273. }
  80274. declare module BABYLON {
  80275. /**
  80276. * Mode that determines the coordinate system to use.
  80277. */
  80278. export enum GLTFLoaderCoordinateSystemMode {
  80279. /**
  80280. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80281. */
  80282. AUTO = 0,
  80283. /**
  80284. * Sets the useRightHandedSystem flag on the scene.
  80285. */
  80286. FORCE_RIGHT_HANDED = 1
  80287. }
  80288. /**
  80289. * Mode that determines what animations will start.
  80290. */
  80291. export enum GLTFLoaderAnimationStartMode {
  80292. /**
  80293. * No animation will start.
  80294. */
  80295. NONE = 0,
  80296. /**
  80297. * The first animation will start.
  80298. */
  80299. FIRST = 1,
  80300. /**
  80301. * All animations will start.
  80302. */
  80303. ALL = 2
  80304. }
  80305. /**
  80306. * Interface that contains the data for the glTF asset.
  80307. */
  80308. export interface IGLTFLoaderData {
  80309. /**
  80310. * The object that represents the glTF JSON.
  80311. */
  80312. json: Object;
  80313. /**
  80314. * The BIN chunk of a binary glTF.
  80315. */
  80316. bin: Nullable<IDataBuffer>;
  80317. }
  80318. /**
  80319. * Interface for extending the loader.
  80320. */
  80321. export interface IGLTFLoaderExtension {
  80322. /**
  80323. * The name of this extension.
  80324. */
  80325. readonly name: string;
  80326. /**
  80327. * Defines whether this extension is enabled.
  80328. */
  80329. enabled: boolean;
  80330. /**
  80331. * Defines the order of this extension.
  80332. * The loader sorts the extensions using these values when loading.
  80333. */
  80334. order?: number;
  80335. }
  80336. /**
  80337. * Loader state.
  80338. */
  80339. export enum GLTFLoaderState {
  80340. /**
  80341. * The asset is loading.
  80342. */
  80343. LOADING = 0,
  80344. /**
  80345. * The asset is ready for rendering.
  80346. */
  80347. READY = 1,
  80348. /**
  80349. * The asset is completely loaded.
  80350. */
  80351. COMPLETE = 2
  80352. }
  80353. /** @hidden */
  80354. export interface IImportMeshAsyncOutput {
  80355. meshes: AbstractMesh[];
  80356. particleSystems: IParticleSystem[];
  80357. skeletons: Skeleton[];
  80358. animationGroups: AnimationGroup[];
  80359. lights: Light[];
  80360. transformNodes: TransformNode[];
  80361. }
  80362. /** @hidden */
  80363. export interface IGLTFLoader extends IDisposable {
  80364. readonly state: Nullable<GLTFLoaderState>;
  80365. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80366. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80367. }
  80368. /**
  80369. * File loader for loading glTF files into a scene.
  80370. */
  80371. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80372. /** @hidden */
  80373. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80374. /** @hidden */
  80375. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80376. /**
  80377. * Raised when the asset has been parsed
  80378. */
  80379. onParsedObservable: Observable<IGLTFLoaderData>;
  80380. private _onParsedObserver;
  80381. /**
  80382. * Raised when the asset has been parsed
  80383. */
  80384. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80385. /**
  80386. * 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.
  80387. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80388. * Defaults to true.
  80389. * @hidden
  80390. */
  80391. static IncrementalLoading: boolean;
  80392. /**
  80393. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80394. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80395. * @hidden
  80396. */
  80397. static HomogeneousCoordinates: boolean;
  80398. /**
  80399. * The coordinate system mode. Defaults to AUTO.
  80400. */
  80401. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80402. /**
  80403. * The animation start mode. Defaults to FIRST.
  80404. */
  80405. animationStartMode: GLTFLoaderAnimationStartMode;
  80406. /**
  80407. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80408. */
  80409. compileMaterials: boolean;
  80410. /**
  80411. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80412. */
  80413. useClipPlane: boolean;
  80414. /**
  80415. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80416. */
  80417. compileShadowGenerators: boolean;
  80418. /**
  80419. * Defines if the Alpha blended materials are only applied as coverage.
  80420. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80421. * If true, no extra effects are applied to transparent pixels.
  80422. */
  80423. transparencyAsCoverage: boolean;
  80424. /**
  80425. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80426. * Enabling will disable offline support and glTF validator.
  80427. * Defaults to false.
  80428. */
  80429. useRangeRequests: boolean;
  80430. /**
  80431. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80432. */
  80433. createInstances: boolean;
  80434. /**
  80435. * 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.
  80436. */
  80437. alwaysComputeBoundingBox: boolean;
  80438. /**
  80439. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80440. */
  80441. loadAllMaterials: boolean;
  80442. /**
  80443. * Function called before loading a url referenced by the asset.
  80444. */
  80445. preprocessUrlAsync: (url: string) => Promise<string>;
  80446. /**
  80447. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80448. * 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, ...)
  80449. */
  80450. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80451. private _onMeshLoadedObserver;
  80452. /**
  80453. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80454. * 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, ...)
  80455. */
  80456. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80457. /**
  80458. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80459. */
  80460. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80461. private _onTextureLoadedObserver;
  80462. /**
  80463. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80464. */
  80465. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80466. /**
  80467. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80468. */
  80469. readonly onMaterialLoadedObservable: Observable<Material>;
  80470. private _onMaterialLoadedObserver;
  80471. /**
  80472. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80473. */
  80474. set onMaterialLoaded(callback: (material: Material) => void);
  80475. /**
  80476. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80477. */
  80478. readonly onCameraLoadedObservable: Observable<Camera>;
  80479. private _onCameraLoadedObserver;
  80480. /**
  80481. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80482. */
  80483. set onCameraLoaded(callback: (camera: Camera) => void);
  80484. /**
  80485. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80486. * For assets with LODs, raised when all of the LODs are complete.
  80487. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80488. */
  80489. readonly onCompleteObservable: Observable<void>;
  80490. private _onCompleteObserver;
  80491. /**
  80492. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80493. * For assets with LODs, raised when all of the LODs are complete.
  80494. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80495. */
  80496. set onComplete(callback: () => void);
  80497. /**
  80498. * Observable raised when an error occurs.
  80499. */
  80500. readonly onErrorObservable: Observable<any>;
  80501. private _onErrorObserver;
  80502. /**
  80503. * Callback raised when an error occurs.
  80504. */
  80505. set onError(callback: (reason: any) => void);
  80506. /**
  80507. * Observable raised after the loader is disposed.
  80508. */
  80509. readonly onDisposeObservable: Observable<void>;
  80510. private _onDisposeObserver;
  80511. /**
  80512. * Callback raised after the loader is disposed.
  80513. */
  80514. set onDispose(callback: () => void);
  80515. /**
  80516. * Observable raised after a loader extension is created.
  80517. * Set additional options for a loader extension in this event.
  80518. */
  80519. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80520. private _onExtensionLoadedObserver;
  80521. /**
  80522. * Callback raised after a loader extension is created.
  80523. */
  80524. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80525. /**
  80526. * Defines if the loader logging is enabled.
  80527. */
  80528. get loggingEnabled(): boolean;
  80529. set loggingEnabled(value: boolean);
  80530. /**
  80531. * Defines if the loader should capture performance counters.
  80532. */
  80533. get capturePerformanceCounters(): boolean;
  80534. set capturePerformanceCounters(value: boolean);
  80535. /**
  80536. * Defines if the loader should validate the asset.
  80537. */
  80538. validate: boolean;
  80539. /**
  80540. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80541. */
  80542. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80543. private _onValidatedObserver;
  80544. /**
  80545. * Callback raised after a loader extension is created.
  80546. */
  80547. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80548. private _loader;
  80549. private _progressCallback?;
  80550. private _requests;
  80551. private static magicBase64Encoded;
  80552. /**
  80553. * Name of the loader ("gltf")
  80554. */
  80555. name: string;
  80556. /** @hidden */
  80557. extensions: ISceneLoaderPluginExtensions;
  80558. /**
  80559. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80560. */
  80561. dispose(): void;
  80562. /** @hidden */
  80563. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80564. /** @hidden */
  80565. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80566. /** @hidden */
  80567. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80568. meshes: AbstractMesh[];
  80569. particleSystems: IParticleSystem[];
  80570. skeletons: Skeleton[];
  80571. animationGroups: AnimationGroup[];
  80572. }>;
  80573. /** @hidden */
  80574. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80575. /** @hidden */
  80576. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80577. /** @hidden */
  80578. canDirectLoad(data: string): boolean;
  80579. /** @hidden */
  80580. directLoad(scene: Scene, data: string): Promise<any>;
  80581. /**
  80582. * The callback that allows custom handling of the root url based on the response url.
  80583. * @param rootUrl the original root url
  80584. * @param responseURL the response url if available
  80585. * @returns the new root url
  80586. */
  80587. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80588. /** @hidden */
  80589. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80590. /**
  80591. * The loader state or null if the loader is not active.
  80592. */
  80593. get loaderState(): Nullable<GLTFLoaderState>;
  80594. /**
  80595. * Returns a promise that resolves when the asset is completely loaded.
  80596. * @returns a promise that resolves when the asset is completely loaded.
  80597. */
  80598. whenCompleteAsync(): Promise<void>;
  80599. /** @hidden */
  80600. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80601. /** @hidden */
  80602. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80603. private _onProgress;
  80604. private _validate;
  80605. private _getLoader;
  80606. private _parseJson;
  80607. private _unpackBinaryAsync;
  80608. private _unpackBinaryV1Async;
  80609. private _unpackBinaryV2Async;
  80610. private static _parseVersion;
  80611. private static _compareVersion;
  80612. private static readonly _logSpaces;
  80613. private _logIndentLevel;
  80614. private _loggingEnabled;
  80615. /** @hidden */
  80616. _log: (message: string) => void;
  80617. /** @hidden */
  80618. _logOpen(message: string): void;
  80619. /** @hidden */
  80620. _logClose(): void;
  80621. private _logEnabled;
  80622. private _logDisabled;
  80623. private _capturePerformanceCounters;
  80624. /** @hidden */
  80625. _startPerformanceCounter: (counterName: string) => void;
  80626. /** @hidden */
  80627. _endPerformanceCounter: (counterName: string) => void;
  80628. private _startPerformanceCounterEnabled;
  80629. private _startPerformanceCounterDisabled;
  80630. private _endPerformanceCounterEnabled;
  80631. private _endPerformanceCounterDisabled;
  80632. }
  80633. }
  80634. declare module BABYLON.GLTF1 {
  80635. /**
  80636. * Enums
  80637. * @hidden
  80638. */
  80639. export enum EComponentType {
  80640. BYTE = 5120,
  80641. UNSIGNED_BYTE = 5121,
  80642. SHORT = 5122,
  80643. UNSIGNED_SHORT = 5123,
  80644. FLOAT = 5126
  80645. }
  80646. /** @hidden */
  80647. export enum EShaderType {
  80648. FRAGMENT = 35632,
  80649. VERTEX = 35633
  80650. }
  80651. /** @hidden */
  80652. export enum EParameterType {
  80653. BYTE = 5120,
  80654. UNSIGNED_BYTE = 5121,
  80655. SHORT = 5122,
  80656. UNSIGNED_SHORT = 5123,
  80657. INT = 5124,
  80658. UNSIGNED_INT = 5125,
  80659. FLOAT = 5126,
  80660. FLOAT_VEC2 = 35664,
  80661. FLOAT_VEC3 = 35665,
  80662. FLOAT_VEC4 = 35666,
  80663. INT_VEC2 = 35667,
  80664. INT_VEC3 = 35668,
  80665. INT_VEC4 = 35669,
  80666. BOOL = 35670,
  80667. BOOL_VEC2 = 35671,
  80668. BOOL_VEC3 = 35672,
  80669. BOOL_VEC4 = 35673,
  80670. FLOAT_MAT2 = 35674,
  80671. FLOAT_MAT3 = 35675,
  80672. FLOAT_MAT4 = 35676,
  80673. SAMPLER_2D = 35678
  80674. }
  80675. /** @hidden */
  80676. export enum ETextureWrapMode {
  80677. CLAMP_TO_EDGE = 33071,
  80678. MIRRORED_REPEAT = 33648,
  80679. REPEAT = 10497
  80680. }
  80681. /** @hidden */
  80682. export enum ETextureFilterType {
  80683. NEAREST = 9728,
  80684. LINEAR = 9728,
  80685. NEAREST_MIPMAP_NEAREST = 9984,
  80686. LINEAR_MIPMAP_NEAREST = 9985,
  80687. NEAREST_MIPMAP_LINEAR = 9986,
  80688. LINEAR_MIPMAP_LINEAR = 9987
  80689. }
  80690. /** @hidden */
  80691. export enum ETextureFormat {
  80692. ALPHA = 6406,
  80693. RGB = 6407,
  80694. RGBA = 6408,
  80695. LUMINANCE = 6409,
  80696. LUMINANCE_ALPHA = 6410
  80697. }
  80698. /** @hidden */
  80699. export enum ECullingType {
  80700. FRONT = 1028,
  80701. BACK = 1029,
  80702. FRONT_AND_BACK = 1032
  80703. }
  80704. /** @hidden */
  80705. export enum EBlendingFunction {
  80706. ZERO = 0,
  80707. ONE = 1,
  80708. SRC_COLOR = 768,
  80709. ONE_MINUS_SRC_COLOR = 769,
  80710. DST_COLOR = 774,
  80711. ONE_MINUS_DST_COLOR = 775,
  80712. SRC_ALPHA = 770,
  80713. ONE_MINUS_SRC_ALPHA = 771,
  80714. DST_ALPHA = 772,
  80715. ONE_MINUS_DST_ALPHA = 773,
  80716. CONSTANT_COLOR = 32769,
  80717. ONE_MINUS_CONSTANT_COLOR = 32770,
  80718. CONSTANT_ALPHA = 32771,
  80719. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80720. SRC_ALPHA_SATURATE = 776
  80721. }
  80722. /** @hidden */
  80723. export interface IGLTFProperty {
  80724. extensions?: {
  80725. [key: string]: any;
  80726. };
  80727. extras?: Object;
  80728. }
  80729. /** @hidden */
  80730. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80731. name?: string;
  80732. }
  80733. /** @hidden */
  80734. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80735. bufferView: string;
  80736. byteOffset: number;
  80737. byteStride: number;
  80738. count: number;
  80739. type: string;
  80740. componentType: EComponentType;
  80741. max?: number[];
  80742. min?: number[];
  80743. name?: string;
  80744. }
  80745. /** @hidden */
  80746. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80747. buffer: string;
  80748. byteOffset: number;
  80749. byteLength: number;
  80750. byteStride: number;
  80751. target?: number;
  80752. }
  80753. /** @hidden */
  80754. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80755. uri: string;
  80756. byteLength?: number;
  80757. type?: string;
  80758. }
  80759. /** @hidden */
  80760. export interface IGLTFShader extends IGLTFChildRootProperty {
  80761. uri: string;
  80762. type: EShaderType;
  80763. }
  80764. /** @hidden */
  80765. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80766. attributes: string[];
  80767. fragmentShader: string;
  80768. vertexShader: string;
  80769. }
  80770. /** @hidden */
  80771. export interface IGLTFTechniqueParameter {
  80772. type: number;
  80773. count?: number;
  80774. semantic?: string;
  80775. node?: string;
  80776. value?: number | boolean | string | Array<any>;
  80777. source?: string;
  80778. babylonValue?: any;
  80779. }
  80780. /** @hidden */
  80781. export interface IGLTFTechniqueCommonProfile {
  80782. lightingModel: string;
  80783. texcoordBindings: Object;
  80784. parameters?: Array<any>;
  80785. }
  80786. /** @hidden */
  80787. export interface IGLTFTechniqueStatesFunctions {
  80788. blendColor?: number[];
  80789. blendEquationSeparate?: number[];
  80790. blendFuncSeparate?: number[];
  80791. colorMask: boolean[];
  80792. cullFace: number[];
  80793. }
  80794. /** @hidden */
  80795. export interface IGLTFTechniqueStates {
  80796. enable: number[];
  80797. functions: IGLTFTechniqueStatesFunctions;
  80798. }
  80799. /** @hidden */
  80800. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80801. parameters: {
  80802. [key: string]: IGLTFTechniqueParameter;
  80803. };
  80804. program: string;
  80805. attributes: {
  80806. [key: string]: string;
  80807. };
  80808. uniforms: {
  80809. [key: string]: string;
  80810. };
  80811. states: IGLTFTechniqueStates;
  80812. }
  80813. /** @hidden */
  80814. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80815. technique?: string;
  80816. values: string[];
  80817. }
  80818. /** @hidden */
  80819. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80820. attributes: {
  80821. [key: string]: string;
  80822. };
  80823. indices: string;
  80824. material: string;
  80825. mode?: number;
  80826. }
  80827. /** @hidden */
  80828. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80829. primitives: IGLTFMeshPrimitive[];
  80830. }
  80831. /** @hidden */
  80832. export interface IGLTFImage extends IGLTFChildRootProperty {
  80833. uri: string;
  80834. }
  80835. /** @hidden */
  80836. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80837. magFilter?: number;
  80838. minFilter?: number;
  80839. wrapS?: number;
  80840. wrapT?: number;
  80841. }
  80842. /** @hidden */
  80843. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80844. sampler: string;
  80845. source: string;
  80846. format?: ETextureFormat;
  80847. internalFormat?: ETextureFormat;
  80848. target?: number;
  80849. type?: number;
  80850. babylonTexture?: Texture;
  80851. }
  80852. /** @hidden */
  80853. export interface IGLTFAmbienLight {
  80854. color?: number[];
  80855. }
  80856. /** @hidden */
  80857. export interface IGLTFDirectionalLight {
  80858. color?: number[];
  80859. }
  80860. /** @hidden */
  80861. export interface IGLTFPointLight {
  80862. color?: number[];
  80863. constantAttenuation?: number;
  80864. linearAttenuation?: number;
  80865. quadraticAttenuation?: number;
  80866. }
  80867. /** @hidden */
  80868. export interface IGLTFSpotLight {
  80869. color?: number[];
  80870. constantAttenuation?: number;
  80871. fallOfAngle?: number;
  80872. fallOffExponent?: number;
  80873. linearAttenuation?: number;
  80874. quadraticAttenuation?: number;
  80875. }
  80876. /** @hidden */
  80877. export interface IGLTFLight extends IGLTFChildRootProperty {
  80878. type: string;
  80879. }
  80880. /** @hidden */
  80881. export interface IGLTFCameraOrthographic {
  80882. xmag: number;
  80883. ymag: number;
  80884. zfar: number;
  80885. znear: number;
  80886. }
  80887. /** @hidden */
  80888. export interface IGLTFCameraPerspective {
  80889. aspectRatio: number;
  80890. yfov: number;
  80891. zfar: number;
  80892. znear: number;
  80893. }
  80894. /** @hidden */
  80895. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80896. type: string;
  80897. }
  80898. /** @hidden */
  80899. export interface IGLTFAnimationChannelTarget {
  80900. id: string;
  80901. path: string;
  80902. }
  80903. /** @hidden */
  80904. export interface IGLTFAnimationChannel {
  80905. sampler: string;
  80906. target: IGLTFAnimationChannelTarget;
  80907. }
  80908. /** @hidden */
  80909. export interface IGLTFAnimationSampler {
  80910. input: string;
  80911. output: string;
  80912. interpolation?: string;
  80913. }
  80914. /** @hidden */
  80915. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80916. channels?: IGLTFAnimationChannel[];
  80917. parameters?: {
  80918. [key: string]: string;
  80919. };
  80920. samplers?: {
  80921. [key: string]: IGLTFAnimationSampler;
  80922. };
  80923. }
  80924. /** @hidden */
  80925. export interface IGLTFNodeInstanceSkin {
  80926. skeletons: string[];
  80927. skin: string;
  80928. meshes: string[];
  80929. }
  80930. /** @hidden */
  80931. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80932. bindShapeMatrix: number[];
  80933. inverseBindMatrices: string;
  80934. jointNames: string[];
  80935. babylonSkeleton?: Skeleton;
  80936. }
  80937. /** @hidden */
  80938. export interface IGLTFNode extends IGLTFChildRootProperty {
  80939. camera?: string;
  80940. children: string[];
  80941. skin?: string;
  80942. jointName?: string;
  80943. light?: string;
  80944. matrix: number[];
  80945. mesh?: string;
  80946. meshes?: string[];
  80947. rotation?: number[];
  80948. scale?: number[];
  80949. translation?: number[];
  80950. babylonNode?: Node;
  80951. }
  80952. /** @hidden */
  80953. export interface IGLTFScene extends IGLTFChildRootProperty {
  80954. nodes: string[];
  80955. }
  80956. /** @hidden */
  80957. export interface IGLTFRuntime {
  80958. extensions: {
  80959. [key: string]: any;
  80960. };
  80961. accessors: {
  80962. [key: string]: IGLTFAccessor;
  80963. };
  80964. buffers: {
  80965. [key: string]: IGLTFBuffer;
  80966. };
  80967. bufferViews: {
  80968. [key: string]: IGLTFBufferView;
  80969. };
  80970. meshes: {
  80971. [key: string]: IGLTFMesh;
  80972. };
  80973. lights: {
  80974. [key: string]: IGLTFLight;
  80975. };
  80976. cameras: {
  80977. [key: string]: IGLTFCamera;
  80978. };
  80979. nodes: {
  80980. [key: string]: IGLTFNode;
  80981. };
  80982. images: {
  80983. [key: string]: IGLTFImage;
  80984. };
  80985. textures: {
  80986. [key: string]: IGLTFTexture;
  80987. };
  80988. shaders: {
  80989. [key: string]: IGLTFShader;
  80990. };
  80991. programs: {
  80992. [key: string]: IGLTFProgram;
  80993. };
  80994. samplers: {
  80995. [key: string]: IGLTFSampler;
  80996. };
  80997. techniques: {
  80998. [key: string]: IGLTFTechnique;
  80999. };
  81000. materials: {
  81001. [key: string]: IGLTFMaterial;
  81002. };
  81003. animations: {
  81004. [key: string]: IGLTFAnimation;
  81005. };
  81006. skins: {
  81007. [key: string]: IGLTFSkins;
  81008. };
  81009. currentScene?: Object;
  81010. scenes: {
  81011. [key: string]: IGLTFScene;
  81012. };
  81013. extensionsUsed: string[];
  81014. extensionsRequired?: string[];
  81015. buffersCount: number;
  81016. shaderscount: number;
  81017. scene: Scene;
  81018. rootUrl: string;
  81019. loadedBufferCount: number;
  81020. loadedBufferViews: {
  81021. [name: string]: ArrayBufferView;
  81022. };
  81023. loadedShaderCount: number;
  81024. importOnlyMeshes: boolean;
  81025. importMeshesNames?: string[];
  81026. dummyNodes: Node[];
  81027. forAssetContainer: boolean;
  81028. }
  81029. /** @hidden */
  81030. export interface INodeToRoot {
  81031. bone: Bone;
  81032. node: IGLTFNode;
  81033. id: string;
  81034. }
  81035. /** @hidden */
  81036. export interface IJointNode {
  81037. node: IGLTFNode;
  81038. id: string;
  81039. }
  81040. }
  81041. declare module BABYLON.GLTF1 {
  81042. /**
  81043. * Utils functions for GLTF
  81044. * @hidden
  81045. */
  81046. export class GLTFUtils {
  81047. /**
  81048. * Sets the given "parameter" matrix
  81049. * @param scene: the Scene object
  81050. * @param source: the source node where to pick the matrix
  81051. * @param parameter: the GLTF technique parameter
  81052. * @param uniformName: the name of the shader's uniform
  81053. * @param shaderMaterial: the shader material
  81054. */
  81055. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81056. /**
  81057. * Sets the given "parameter" matrix
  81058. * @param shaderMaterial: the shader material
  81059. * @param uniform: the name of the shader's uniform
  81060. * @param value: the value of the uniform
  81061. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81062. */
  81063. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81064. /**
  81065. * Returns the wrap mode of the texture
  81066. * @param mode: the mode value
  81067. */
  81068. static GetWrapMode(mode: number): number;
  81069. /**
  81070. * Returns the byte stride giving an accessor
  81071. * @param accessor: the GLTF accessor objet
  81072. */
  81073. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81074. /**
  81075. * Returns the texture filter mode giving a mode value
  81076. * @param mode: the filter mode value
  81077. */
  81078. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81079. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81080. /**
  81081. * Returns a buffer from its accessor
  81082. * @param gltfRuntime: the GLTF runtime
  81083. * @param accessor: the GLTF accessor
  81084. */
  81085. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81086. /**
  81087. * Decodes a buffer view into a string
  81088. * @param view: the buffer view
  81089. */
  81090. static DecodeBufferToText(view: ArrayBufferView): string;
  81091. /**
  81092. * Returns the default material of gltf. Related to
  81093. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81094. * @param scene: the Babylon.js scene
  81095. */
  81096. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81097. private static _DefaultMaterial;
  81098. }
  81099. }
  81100. declare module BABYLON.GLTF1 {
  81101. /**
  81102. * Implementation of the base glTF spec
  81103. * @hidden
  81104. */
  81105. export class GLTFLoaderBase {
  81106. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81107. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81108. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81109. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81110. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81111. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81112. }
  81113. /**
  81114. * glTF V1 Loader
  81115. * @hidden
  81116. */
  81117. export class GLTFLoader implements IGLTFLoader {
  81118. static Extensions: {
  81119. [name: string]: GLTFLoaderExtension;
  81120. };
  81121. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81122. state: Nullable<GLTFLoaderState>;
  81123. dispose(): void;
  81124. private _importMeshAsync;
  81125. /**
  81126. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81127. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81128. * @param scene the scene the meshes should be added to
  81129. * @param forAssetContainer defines if the entities must be stored in the scene
  81130. * @param data gltf data containing information of the meshes in a loaded file
  81131. * @param rootUrl root url to load from
  81132. * @param onProgress event that fires when loading progress has occured
  81133. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81134. */
  81135. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81136. private _loadAsync;
  81137. /**
  81138. * Imports all objects from a loaded gltf file and adds them to the scene
  81139. * @param scene the scene the objects should be added to
  81140. * @param data gltf data containing information of the meshes in a loaded file
  81141. * @param rootUrl root url to load from
  81142. * @param onProgress event that fires when loading progress has occured
  81143. * @returns a promise which completes when objects have been loaded to the scene
  81144. */
  81145. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81146. private _loadShadersAsync;
  81147. private _loadBuffersAsync;
  81148. private _createNodes;
  81149. }
  81150. /** @hidden */
  81151. export abstract class GLTFLoaderExtension {
  81152. private _name;
  81153. constructor(name: string);
  81154. get name(): string;
  81155. /**
  81156. * Defines an override for loading the runtime
  81157. * Return true to stop further extensions from loading the runtime
  81158. */
  81159. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81160. /**
  81161. * Defines an onverride for creating gltf runtime
  81162. * Return true to stop further extensions from creating the runtime
  81163. */
  81164. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81165. /**
  81166. * Defines an override for loading buffers
  81167. * Return true to stop further extensions from loading this buffer
  81168. */
  81169. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81170. /**
  81171. * Defines an override for loading texture buffers
  81172. * Return true to stop further extensions from loading this texture data
  81173. */
  81174. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81175. /**
  81176. * Defines an override for creating textures
  81177. * Return true to stop further extensions from loading this texture
  81178. */
  81179. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81180. /**
  81181. * Defines an override for loading shader strings
  81182. * Return true to stop further extensions from loading this shader data
  81183. */
  81184. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81185. /**
  81186. * Defines an override for loading materials
  81187. * Return true to stop further extensions from loading this material
  81188. */
  81189. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81190. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81191. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81192. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81193. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81194. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81195. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81196. private static LoadTextureBufferAsync;
  81197. private static CreateTextureAsync;
  81198. private static ApplyExtensions;
  81199. }
  81200. }
  81201. declare module BABYLON.GLTF1 {
  81202. /** @hidden */
  81203. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81204. private _bin;
  81205. constructor();
  81206. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81207. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81208. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81209. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81210. }
  81211. }
  81212. declare module BABYLON.GLTF1 {
  81213. /** @hidden */
  81214. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81215. constructor();
  81216. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81217. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81218. private _loadTexture;
  81219. }
  81220. }
  81221. declare module BABYLON.GLTF2.Loader {
  81222. /**
  81223. * Loader interface with an index field.
  81224. */
  81225. export interface IArrayItem {
  81226. /**
  81227. * The index of this item in the array.
  81228. */
  81229. index: number;
  81230. }
  81231. /**
  81232. * Loader interface with additional members.
  81233. */
  81234. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81235. /** @hidden */
  81236. _data?: Promise<ArrayBufferView>;
  81237. /** @hidden */
  81238. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81239. }
  81240. /**
  81241. * Loader interface with additional members.
  81242. */
  81243. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81244. }
  81245. /** @hidden */
  81246. export interface _IAnimationSamplerData {
  81247. input: Float32Array;
  81248. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81249. output: Float32Array;
  81250. }
  81251. /**
  81252. * Loader interface with additional members.
  81253. */
  81254. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81255. /** @hidden */
  81256. _data?: Promise<_IAnimationSamplerData>;
  81257. }
  81258. /**
  81259. * Loader interface with additional members.
  81260. */
  81261. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81262. channels: IAnimationChannel[];
  81263. samplers: IAnimationSampler[];
  81264. /** @hidden */
  81265. _babylonAnimationGroup?: AnimationGroup;
  81266. }
  81267. /**
  81268. * Loader interface with additional members.
  81269. */
  81270. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81271. /** @hidden */
  81272. _data?: Promise<ArrayBufferView>;
  81273. }
  81274. /**
  81275. * Loader interface with additional members.
  81276. */
  81277. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81278. /** @hidden */
  81279. _data?: Promise<ArrayBufferView>;
  81280. /** @hidden */
  81281. _babylonBuffer?: Promise<Buffer>;
  81282. }
  81283. /**
  81284. * Loader interface with additional members.
  81285. */
  81286. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81287. }
  81288. /**
  81289. * Loader interface with additional members.
  81290. */
  81291. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81292. /** @hidden */
  81293. _data?: Promise<ArrayBufferView>;
  81294. }
  81295. /**
  81296. * Loader interface with additional members.
  81297. */
  81298. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81299. }
  81300. /**
  81301. * Loader interface with additional members.
  81302. */
  81303. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81304. }
  81305. /**
  81306. * Loader interface with additional members.
  81307. */
  81308. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81309. baseColorTexture?: ITextureInfo;
  81310. metallicRoughnessTexture?: ITextureInfo;
  81311. }
  81312. /**
  81313. * Loader interface with additional members.
  81314. */
  81315. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81316. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81317. normalTexture?: IMaterialNormalTextureInfo;
  81318. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81319. emissiveTexture?: ITextureInfo;
  81320. /** @hidden */
  81321. _data?: {
  81322. [babylonDrawMode: number]: {
  81323. babylonMaterial: Material;
  81324. babylonMeshes: AbstractMesh[];
  81325. promise: Promise<void>;
  81326. };
  81327. };
  81328. }
  81329. /**
  81330. * Loader interface with additional members.
  81331. */
  81332. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81333. primitives: IMeshPrimitive[];
  81334. }
  81335. /**
  81336. * Loader interface with additional members.
  81337. */
  81338. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81339. /** @hidden */
  81340. _instanceData?: {
  81341. babylonSourceMesh: Mesh;
  81342. promise: Promise<any>;
  81343. };
  81344. }
  81345. /**
  81346. * Loader interface with additional members.
  81347. */
  81348. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81349. /**
  81350. * The parent glTF node.
  81351. */
  81352. parent?: INode;
  81353. /** @hidden */
  81354. _babylonTransformNode?: TransformNode;
  81355. /** @hidden */
  81356. _primitiveBabylonMeshes?: AbstractMesh[];
  81357. /** @hidden */
  81358. _babylonBones?: Bone[];
  81359. /** @hidden */
  81360. _numMorphTargets?: number;
  81361. }
  81362. /** @hidden */
  81363. export interface _ISamplerData {
  81364. noMipMaps: boolean;
  81365. samplingMode: number;
  81366. wrapU: number;
  81367. wrapV: number;
  81368. }
  81369. /**
  81370. * Loader interface with additional members.
  81371. */
  81372. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81373. /** @hidden */
  81374. _data?: _ISamplerData;
  81375. }
  81376. /**
  81377. * Loader interface with additional members.
  81378. */
  81379. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81380. }
  81381. /**
  81382. * Loader interface with additional members.
  81383. */
  81384. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81385. /** @hidden */
  81386. _data?: {
  81387. babylonSkeleton: Skeleton;
  81388. promise: Promise<void>;
  81389. };
  81390. }
  81391. /**
  81392. * Loader interface with additional members.
  81393. */
  81394. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81395. }
  81396. /**
  81397. * Loader interface with additional members.
  81398. */
  81399. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81400. }
  81401. /**
  81402. * Loader interface with additional members.
  81403. */
  81404. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81405. accessors?: IAccessor[];
  81406. animations?: IAnimation[];
  81407. buffers?: IBuffer[];
  81408. bufferViews?: IBufferView[];
  81409. cameras?: ICamera[];
  81410. images?: IImage[];
  81411. materials?: IMaterial[];
  81412. meshes?: IMesh[];
  81413. nodes?: INode[];
  81414. samplers?: ISampler[];
  81415. scenes?: IScene[];
  81416. skins?: ISkin[];
  81417. textures?: ITexture[];
  81418. }
  81419. }
  81420. declare module BABYLON.GLTF2 {
  81421. /**
  81422. * Interface for a glTF loader extension.
  81423. */
  81424. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81425. /**
  81426. * Called after the loader state changes to LOADING.
  81427. */
  81428. onLoading?(): void;
  81429. /**
  81430. * Called after the loader state changes to READY.
  81431. */
  81432. onReady?(): void;
  81433. /**
  81434. * Define this method to modify the default behavior when loading scenes.
  81435. * @param context The context when loading the asset
  81436. * @param scene The glTF scene property
  81437. * @returns A promise that resolves when the load is complete or null if not handled
  81438. */
  81439. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81440. /**
  81441. * Define this method to modify the default behavior when loading nodes.
  81442. * @param context The context when loading the asset
  81443. * @param node The glTF node property
  81444. * @param assign A function called synchronously after parsing the glTF properties
  81445. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81446. */
  81447. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81448. /**
  81449. * Define this method to modify the default behavior when loading cameras.
  81450. * @param context The context when loading the asset
  81451. * @param camera The glTF camera property
  81452. * @param assign A function called synchronously after parsing the glTF properties
  81453. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81454. */
  81455. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81456. /**
  81457. * @hidden
  81458. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81459. * @param context The context when loading the asset
  81460. * @param primitive The glTF mesh primitive property
  81461. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81462. */
  81463. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81464. /**
  81465. * @hidden
  81466. * Define this method to modify the default behavior when loading data for mesh primitives.
  81467. * @param context The context when loading the asset
  81468. * @param name The mesh name when loading the asset
  81469. * @param node The glTF node when loading the asset
  81470. * @param mesh The glTF mesh when loading the asset
  81471. * @param primitive The glTF mesh primitive property
  81472. * @param assign A function called synchronously after parsing the glTF properties
  81473. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81474. */
  81475. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81476. /**
  81477. * @hidden
  81478. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81479. * @param context The context when loading the asset
  81480. * @param material The glTF material property
  81481. * @param assign A function called synchronously after parsing the glTF properties
  81482. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81483. */
  81484. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81485. /**
  81486. * Define this method to modify the default behavior when creating materials.
  81487. * @param context The context when loading the asset
  81488. * @param material The glTF material property
  81489. * @param babylonDrawMode The draw mode for the Babylon material
  81490. * @returns The Babylon material or null if not handled
  81491. */
  81492. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81493. /**
  81494. * Define this method to modify the default behavior when loading material properties.
  81495. * @param context The context when loading the asset
  81496. * @param material The glTF material property
  81497. * @param babylonMaterial The Babylon material
  81498. * @returns A promise that resolves when the load is complete or null if not handled
  81499. */
  81500. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81501. /**
  81502. * Define this method to modify the default behavior when loading texture infos.
  81503. * @param context The context when loading the asset
  81504. * @param textureInfo The glTF texture info property
  81505. * @param assign A function called synchronously after parsing the glTF properties
  81506. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81507. */
  81508. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81509. /**
  81510. * @hidden
  81511. * Define this method to modify the default behavior when loading textures.
  81512. * @param context The context when loading the asset
  81513. * @param texture The glTF texture property
  81514. * @param assign A function called synchronously after parsing the glTF properties
  81515. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81516. */
  81517. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81518. /**
  81519. * Define this method to modify the default behavior when loading animations.
  81520. * @param context The context when loading the asset
  81521. * @param animation The glTF animation property
  81522. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81523. */
  81524. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81525. /**
  81526. * @hidden
  81527. * Define this method to modify the default behavior when loading skins.
  81528. * @param context The context when loading the asset
  81529. * @param node The glTF node property
  81530. * @param skin The glTF skin property
  81531. * @returns A promise that resolves when the load is complete or null if not handled
  81532. */
  81533. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81534. /**
  81535. * @hidden
  81536. * Define this method to modify the default behavior when loading uris.
  81537. * @param context The context when loading the asset
  81538. * @param property The glTF property associated with the uri
  81539. * @param uri The uri to load
  81540. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81541. */
  81542. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81543. /**
  81544. * Define this method to modify the default behavior when loading buffer views.
  81545. * @param context The context when loading the asset
  81546. * @param bufferView The glTF buffer view property
  81547. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81548. */
  81549. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81550. /**
  81551. * Define this method to modify the default behavior when loading buffers.
  81552. * @param context The context when loading the asset
  81553. * @param buffer The glTF buffer property
  81554. * @param byteOffset The byte offset to load
  81555. * @param byteLength The byte length to load
  81556. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81557. */
  81558. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81559. }
  81560. }
  81561. declare module BABYLON.GLTF2 {
  81562. /**
  81563. * Helper class for working with arrays when loading the glTF asset
  81564. */
  81565. export class ArrayItem {
  81566. /**
  81567. * Gets an item from the given array.
  81568. * @param context The context when loading the asset
  81569. * @param array The array to get the item from
  81570. * @param index The index to the array
  81571. * @returns The array item
  81572. */
  81573. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81574. /**
  81575. * Assign an `index` field to each item of the given array.
  81576. * @param array The array of items
  81577. */
  81578. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81579. }
  81580. /**
  81581. * The glTF 2.0 loader
  81582. */
  81583. export class GLTFLoader implements IGLTFLoader {
  81584. /** @hidden */
  81585. _completePromises: Promise<any>[];
  81586. /** @hidden */
  81587. _forAssetContainer: boolean;
  81588. /** Storage */
  81589. _babylonLights: Light[];
  81590. /** @hidden */
  81591. _disableInstancedMesh: number;
  81592. private _disposed;
  81593. private _parent;
  81594. private _state;
  81595. private _extensions;
  81596. private _rootUrl;
  81597. private _fileName;
  81598. private _uniqueRootUrl;
  81599. private _gltf;
  81600. private _bin;
  81601. private _babylonScene;
  81602. private _rootBabylonMesh;
  81603. private _defaultBabylonMaterialData;
  81604. private static _RegisteredExtensions;
  81605. /**
  81606. * The default glTF sampler.
  81607. */
  81608. static readonly DefaultSampler: ISampler;
  81609. /**
  81610. * Registers a loader extension.
  81611. * @param name The name of the loader extension.
  81612. * @param factory The factory function that creates the loader extension.
  81613. */
  81614. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81615. /**
  81616. * Unregisters a loader extension.
  81617. * @param name The name of the loader extension.
  81618. * @returns A boolean indicating whether the extension has been unregistered
  81619. */
  81620. static UnregisterExtension(name: string): boolean;
  81621. /**
  81622. * The loader state.
  81623. */
  81624. get state(): Nullable<GLTFLoaderState>;
  81625. /**
  81626. * The object that represents the glTF JSON.
  81627. */
  81628. get gltf(): IGLTF;
  81629. /**
  81630. * The BIN chunk of a binary glTF.
  81631. */
  81632. get bin(): Nullable<IDataBuffer>;
  81633. /**
  81634. * The parent file loader.
  81635. */
  81636. get parent(): GLTFFileLoader;
  81637. /**
  81638. * The Babylon scene when loading the asset.
  81639. */
  81640. get babylonScene(): Scene;
  81641. /**
  81642. * The root Babylon mesh when loading the asset.
  81643. */
  81644. get rootBabylonMesh(): Mesh;
  81645. /** @hidden */
  81646. constructor(parent: GLTFFileLoader);
  81647. /** @hidden */
  81648. dispose(): void;
  81649. /** @hidden */
  81650. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81651. /** @hidden */
  81652. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81653. private _loadAsync;
  81654. private _loadData;
  81655. private _setupData;
  81656. private _loadExtensions;
  81657. private _checkExtensions;
  81658. private _setState;
  81659. private _createRootNode;
  81660. /**
  81661. * Loads a glTF scene.
  81662. * @param context The context when loading the asset
  81663. * @param scene The glTF scene property
  81664. * @returns A promise that resolves when the load is complete
  81665. */
  81666. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81667. private _forEachPrimitive;
  81668. private _getMeshes;
  81669. private _getTransformNodes;
  81670. private _getSkeletons;
  81671. private _getAnimationGroups;
  81672. private _startAnimations;
  81673. /**
  81674. * Loads a glTF node.
  81675. * @param context The context when loading the asset
  81676. * @param node The glTF node property
  81677. * @param assign A function called synchronously after parsing the glTF properties
  81678. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81679. */
  81680. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81681. private _loadMeshAsync;
  81682. /**
  81683. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81684. * @param context The context when loading the asset
  81685. * @param name The mesh name when loading the asset
  81686. * @param node The glTF node when loading the asset
  81687. * @param mesh The glTF mesh when loading the asset
  81688. * @param primitive The glTF mesh primitive property
  81689. * @param assign A function called synchronously after parsing the glTF properties
  81690. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81691. */
  81692. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81693. private _loadVertexDataAsync;
  81694. private _createMorphTargets;
  81695. private _loadMorphTargetsAsync;
  81696. private _loadMorphTargetVertexDataAsync;
  81697. private static _LoadTransform;
  81698. private _loadSkinAsync;
  81699. private _loadBones;
  81700. private _loadBone;
  81701. private _loadSkinInverseBindMatricesDataAsync;
  81702. private _updateBoneMatrices;
  81703. private _getNodeMatrix;
  81704. /**
  81705. * Loads a glTF camera.
  81706. * @param context The context when loading the asset
  81707. * @param camera The glTF camera property
  81708. * @param assign A function called synchronously after parsing the glTF properties
  81709. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81710. */
  81711. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81712. private _loadAnimationsAsync;
  81713. /**
  81714. * Loads a glTF animation.
  81715. * @param context The context when loading the asset
  81716. * @param animation The glTF animation property
  81717. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81718. */
  81719. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81720. /**
  81721. * @hidden Loads a glTF animation channel.
  81722. * @param context The context when loading the asset
  81723. * @param animationContext The context of the animation when loading the asset
  81724. * @param animation The glTF animation property
  81725. * @param channel The glTF animation channel property
  81726. * @param babylonAnimationGroup The babylon animation group property
  81727. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81728. * @returns A void promise when the channel load is complete
  81729. */
  81730. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81731. private _loadAnimationSamplerAsync;
  81732. private _loadBufferAsync;
  81733. /**
  81734. * Loads a glTF buffer view.
  81735. * @param context The context when loading the asset
  81736. * @param bufferView The glTF buffer view property
  81737. * @returns A promise that resolves with the loaded data when the load is complete
  81738. */
  81739. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81740. private _loadAccessorAsync;
  81741. /** @hidden */
  81742. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81743. private _loadIndicesAccessorAsync;
  81744. private _loadVertexBufferViewAsync;
  81745. private _loadVertexAccessorAsync;
  81746. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81747. /** @hidden */
  81748. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81749. private _createDefaultMaterial;
  81750. /**
  81751. * Creates a Babylon material from a glTF material.
  81752. * @param context The context when loading the asset
  81753. * @param material The glTF material property
  81754. * @param babylonDrawMode The draw mode for the Babylon material
  81755. * @returns The Babylon material
  81756. */
  81757. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81758. /**
  81759. * Loads properties from a glTF material into a Babylon material.
  81760. * @param context The context when loading the asset
  81761. * @param material The glTF material property
  81762. * @param babylonMaterial The Babylon material
  81763. * @returns A promise that resolves when the load is complete
  81764. */
  81765. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81766. /**
  81767. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81768. * @param context The context when loading the asset
  81769. * @param material The glTF material property
  81770. * @param babylonMaterial The Babylon material
  81771. * @returns A promise that resolves when the load is complete
  81772. */
  81773. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81774. /**
  81775. * Loads the alpha properties from a glTF material into a Babylon material.
  81776. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81777. * @param context The context when loading the asset
  81778. * @param material The glTF material property
  81779. * @param babylonMaterial The Babylon material
  81780. */
  81781. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81782. /**
  81783. * Loads a glTF texture info.
  81784. * @param context The context when loading the asset
  81785. * @param textureInfo The glTF texture info property
  81786. * @param assign A function called synchronously after parsing the glTF properties
  81787. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81788. */
  81789. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81790. /** @hidden */
  81791. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81792. /** @hidden */
  81793. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81794. private _loadSampler;
  81795. /**
  81796. * Loads a glTF image.
  81797. * @param context The context when loading the asset
  81798. * @param image The glTF image property
  81799. * @returns A promise that resolves with the loaded data when the load is complete
  81800. */
  81801. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81802. /**
  81803. * Loads a glTF uri.
  81804. * @param context The context when loading the asset
  81805. * @param property The glTF property associated with the uri
  81806. * @param uri The base64 or relative uri
  81807. * @returns A promise that resolves with the loaded data when the load is complete
  81808. */
  81809. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81810. /**
  81811. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81812. * @param babylonObject the Babylon object with metadata
  81813. * @param pointer the JSON pointer
  81814. */
  81815. static AddPointerMetadata(babylonObject: {
  81816. metadata: any;
  81817. }, pointer: string): void;
  81818. private static _GetTextureWrapMode;
  81819. private static _GetTextureSamplingMode;
  81820. private static _GetTypedArrayConstructor;
  81821. private static _GetTypedArray;
  81822. private static _GetNumComponents;
  81823. private static _ValidateUri;
  81824. /** @hidden */
  81825. static _GetDrawMode(context: string, mode: number | undefined): number;
  81826. private _compileMaterialsAsync;
  81827. private _compileShadowGeneratorsAsync;
  81828. private _forEachExtensions;
  81829. private _applyExtensions;
  81830. private _extensionsOnLoading;
  81831. private _extensionsOnReady;
  81832. private _extensionsLoadSceneAsync;
  81833. private _extensionsLoadNodeAsync;
  81834. private _extensionsLoadCameraAsync;
  81835. private _extensionsLoadVertexDataAsync;
  81836. private _extensionsLoadMeshPrimitiveAsync;
  81837. private _extensionsLoadMaterialAsync;
  81838. private _extensionsCreateMaterial;
  81839. private _extensionsLoadMaterialPropertiesAsync;
  81840. private _extensionsLoadTextureInfoAsync;
  81841. private _extensionsLoadTextureAsync;
  81842. private _extensionsLoadAnimationAsync;
  81843. private _extensionsLoadSkinAsync;
  81844. private _extensionsLoadUriAsync;
  81845. private _extensionsLoadBufferViewAsync;
  81846. private _extensionsLoadBufferAsync;
  81847. /**
  81848. * Helper method called by a loader extension to load an glTF extension.
  81849. * @param context The context when loading the asset
  81850. * @param property The glTF property to load the extension from
  81851. * @param extensionName The name of the extension to load
  81852. * @param actionAsync The action to run
  81853. * @returns The promise returned by actionAsync or null if the extension does not exist
  81854. */
  81855. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81856. /**
  81857. * Helper method called by a loader extension to load a glTF extra.
  81858. * @param context The context when loading the asset
  81859. * @param property The glTF property to load the extra from
  81860. * @param extensionName The name of the extension to load
  81861. * @param actionAsync The action to run
  81862. * @returns The promise returned by actionAsync or null if the extra does not exist
  81863. */
  81864. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81865. /**
  81866. * Checks for presence of an extension.
  81867. * @param name The name of the extension to check
  81868. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81869. */
  81870. isExtensionUsed(name: string): boolean;
  81871. /**
  81872. * Increments the indentation level and logs a message.
  81873. * @param message The message to log
  81874. */
  81875. logOpen(message: string): void;
  81876. /**
  81877. * Decrements the indentation level.
  81878. */
  81879. logClose(): void;
  81880. /**
  81881. * Logs a message
  81882. * @param message The message to log
  81883. */
  81884. log(message: string): void;
  81885. /**
  81886. * Starts a performance counter.
  81887. * @param counterName The name of the performance counter
  81888. */
  81889. startPerformanceCounter(counterName: string): void;
  81890. /**
  81891. * Ends a performance counter.
  81892. * @param counterName The name of the performance counter
  81893. */
  81894. endPerformanceCounter(counterName: string): void;
  81895. }
  81896. }
  81897. declare module BABYLON.GLTF2.Loader.Extensions {
  81898. /** @hidden */
  81899. interface IEXTLightsImageBased_LightImageBased {
  81900. _babylonTexture?: BaseTexture;
  81901. _loaded?: Promise<void>;
  81902. }
  81903. /**
  81904. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81905. */
  81906. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81907. /**
  81908. * The name of this extension.
  81909. */
  81910. readonly name: string;
  81911. /**
  81912. * Defines whether this extension is enabled.
  81913. */
  81914. enabled: boolean;
  81915. private _loader;
  81916. private _lights?;
  81917. /** @hidden */
  81918. constructor(loader: GLTFLoader);
  81919. /** @hidden */
  81920. dispose(): void;
  81921. /** @hidden */
  81922. onLoading(): void;
  81923. /** @hidden */
  81924. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81925. private _loadLightAsync;
  81926. }
  81927. }
  81928. declare module BABYLON.GLTF2.Loader.Extensions {
  81929. /**
  81930. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81931. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81932. * !!! Experimental Extension Subject to Changes !!!
  81933. */
  81934. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81935. /**
  81936. * The name of this extension.
  81937. */
  81938. readonly name: string;
  81939. /**
  81940. * Defines whether this extension is enabled.
  81941. */
  81942. enabled: boolean;
  81943. private _loader;
  81944. /** @hidden */
  81945. constructor(loader: GLTFLoader);
  81946. /** @hidden */
  81947. dispose(): void;
  81948. /** @hidden */
  81949. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81950. }
  81951. }
  81952. declare module BABYLON.GLTF2.Loader.Extensions {
  81953. /**
  81954. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81955. */
  81956. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81957. /** The name of this extension. */
  81958. readonly name: string;
  81959. /** Defines whether this extension is enabled. */
  81960. enabled: boolean;
  81961. private _loader;
  81962. /** @hidden */
  81963. constructor(loader: GLTFLoader);
  81964. /** @hidden */
  81965. dispose(): void;
  81966. /** @hidden */
  81967. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81968. }
  81969. }
  81970. declare module BABYLON.GLTF2.Loader.Extensions {
  81971. /**
  81972. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81973. */
  81974. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81975. /**
  81976. * The name of this extension.
  81977. */
  81978. readonly name: string;
  81979. /**
  81980. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81981. */
  81982. dracoCompression?: DracoCompression;
  81983. /**
  81984. * Defines whether this extension is enabled.
  81985. */
  81986. enabled: boolean;
  81987. private _loader;
  81988. /** @hidden */
  81989. constructor(loader: GLTFLoader);
  81990. /** @hidden */
  81991. dispose(): void;
  81992. /** @hidden */
  81993. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81994. }
  81995. }
  81996. declare module BABYLON.GLTF2.Loader.Extensions {
  81997. /**
  81998. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81999. */
  82000. export class KHR_lights implements IGLTFLoaderExtension {
  82001. /**
  82002. * The name of this extension.
  82003. */
  82004. readonly name: string;
  82005. /**
  82006. * Defines whether this extension is enabled.
  82007. */
  82008. enabled: boolean;
  82009. private _loader;
  82010. private _lights?;
  82011. /** @hidden */
  82012. constructor(loader: GLTFLoader);
  82013. /** @hidden */
  82014. dispose(): void;
  82015. /** @hidden */
  82016. onLoading(): void;
  82017. /** @hidden */
  82018. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82019. }
  82020. }
  82021. declare module BABYLON.GLTF2.Loader.Extensions {
  82022. /**
  82023. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82024. */
  82025. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82026. /**
  82027. * The name of this extension.
  82028. */
  82029. readonly name: string;
  82030. /**
  82031. * Defines whether this extension is enabled.
  82032. */
  82033. enabled: boolean;
  82034. /**
  82035. * Defines a number that determines the order the extensions are applied.
  82036. */
  82037. order: number;
  82038. private _loader;
  82039. /** @hidden */
  82040. constructor(loader: GLTFLoader);
  82041. /** @hidden */
  82042. dispose(): void;
  82043. /** @hidden */
  82044. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82045. private _loadSpecularGlossinessPropertiesAsync;
  82046. }
  82047. }
  82048. declare module BABYLON.GLTF2.Loader.Extensions {
  82049. /**
  82050. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82051. */
  82052. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82053. /**
  82054. * The name of this extension.
  82055. */
  82056. readonly name: string;
  82057. /**
  82058. * Defines whether this extension is enabled.
  82059. */
  82060. enabled: boolean;
  82061. /**
  82062. * Defines a number that determines the order the extensions are applied.
  82063. */
  82064. order: number;
  82065. private _loader;
  82066. /** @hidden */
  82067. constructor(loader: GLTFLoader);
  82068. /** @hidden */
  82069. dispose(): void;
  82070. /** @hidden */
  82071. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82072. private _loadUnlitPropertiesAsync;
  82073. }
  82074. }
  82075. declare module BABYLON.GLTF2.Loader.Extensions {
  82076. /**
  82077. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82078. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82079. * !!! Experimental Extension Subject to Changes !!!
  82080. */
  82081. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82082. /**
  82083. * The name of this extension.
  82084. */
  82085. readonly name: string;
  82086. /**
  82087. * Defines whether this extension is enabled.
  82088. */
  82089. enabled: boolean;
  82090. /**
  82091. * Defines a number that determines the order the extensions are applied.
  82092. */
  82093. order: number;
  82094. private _loader;
  82095. /** @hidden */
  82096. constructor(loader: GLTFLoader);
  82097. /** @hidden */
  82098. dispose(): void;
  82099. /** @hidden */
  82100. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82101. private _loadClearCoatPropertiesAsync;
  82102. }
  82103. }
  82104. declare module BABYLON.GLTF2.Loader.Extensions {
  82105. /**
  82106. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82107. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82108. * !!! Experimental Extension Subject to Changes !!!
  82109. */
  82110. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82111. /**
  82112. * The name of this extension.
  82113. */
  82114. readonly name: string;
  82115. /**
  82116. * Defines whether this extension is enabled.
  82117. */
  82118. enabled: boolean;
  82119. /**
  82120. * Defines a number that determines the order the extensions are applied.
  82121. */
  82122. order: number;
  82123. private _loader;
  82124. /** @hidden */
  82125. constructor(loader: GLTFLoader);
  82126. /** @hidden */
  82127. dispose(): void;
  82128. /** @hidden */
  82129. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82130. private _loadSheenPropertiesAsync;
  82131. }
  82132. }
  82133. declare module BABYLON.GLTF2.Loader.Extensions {
  82134. /**
  82135. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82136. * !!! Experimental Extension Subject to Changes !!!
  82137. */
  82138. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82139. /**
  82140. * The name of this extension.
  82141. */
  82142. readonly name: string;
  82143. /**
  82144. * Defines whether this extension is enabled.
  82145. */
  82146. enabled: boolean;
  82147. /**
  82148. * Defines a number that determines the order the extensions are applied.
  82149. */
  82150. order: number;
  82151. private _loader;
  82152. /** @hidden */
  82153. constructor(loader: GLTFLoader);
  82154. /** @hidden */
  82155. dispose(): void;
  82156. /** @hidden */
  82157. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82158. private _loadSpecularPropertiesAsync;
  82159. }
  82160. }
  82161. declare module BABYLON.GLTF2.Loader.Extensions {
  82162. /**
  82163. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82164. * !!! Experimental Extension Subject to Changes !!!
  82165. */
  82166. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82167. /**
  82168. * Default ior Value from the spec.
  82169. */
  82170. private static readonly _DEFAULT_IOR;
  82171. /**
  82172. * The name of this extension.
  82173. */
  82174. readonly name: string;
  82175. /**
  82176. * Defines whether this extension is enabled.
  82177. */
  82178. enabled: boolean;
  82179. /**
  82180. * Defines a number that determines the order the extensions are applied.
  82181. */
  82182. order: number;
  82183. private _loader;
  82184. /** @hidden */
  82185. constructor(loader: GLTFLoader);
  82186. /** @hidden */
  82187. dispose(): void;
  82188. /** @hidden */
  82189. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82190. private _loadIorPropertiesAsync;
  82191. }
  82192. }
  82193. declare module BABYLON.GLTF2.Loader.Extensions {
  82194. /**
  82195. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82196. * !!! Experimental Extension Subject to Changes !!!
  82197. */
  82198. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82199. /**
  82200. * The name of this extension.
  82201. */
  82202. readonly name: string;
  82203. /**
  82204. * Defines whether this extension is enabled.
  82205. */
  82206. enabled: boolean;
  82207. private _loader;
  82208. private _variants?;
  82209. /** @hidden */
  82210. constructor(loader: GLTFLoader);
  82211. /** @hidden */
  82212. dispose(): void;
  82213. /**
  82214. * Gets the list of available variant names for this asset.
  82215. * @param rootMesh The glTF root mesh
  82216. * @returns the list of all the variant names for this model
  82217. */
  82218. static GetAvailableVariants(rootMesh: Mesh): string[];
  82219. /**
  82220. * Gets the list of available variant names for this asset.
  82221. * @param rootMesh The glTF root mesh
  82222. * @returns the list of all the variant names for this model
  82223. */
  82224. getAvailableVariants(rootMesh: Mesh): string[];
  82225. /**
  82226. * Select a variant given a variant name or a list of variant names.
  82227. * @param rootMesh The glTF root mesh
  82228. * @param variantName The variant name(s) to select.
  82229. */
  82230. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82231. /**
  82232. * Select a variant given a variant name or a list of variant names.
  82233. * @param rootMesh The glTF root mesh
  82234. * @param variantName The variant name(s) to select.
  82235. */
  82236. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82237. /**
  82238. * Reset back to the original before selecting a variant.
  82239. * @param rootMesh The glTF root mesh
  82240. */
  82241. static Reset(rootMesh: Mesh): void;
  82242. /**
  82243. * Reset back to the original before selecting a variant.
  82244. * @param rootMesh The glTF root mesh
  82245. */
  82246. reset(rootMesh: Mesh): void;
  82247. /**
  82248. * Gets the last selected variant name(s) or null if original.
  82249. * @param rootMesh The glTF root mesh
  82250. * @returns The selected variant name(s).
  82251. */
  82252. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82253. /**
  82254. * Gets the last selected variant name(s) or null if original.
  82255. * @param rootMesh The glTF root mesh
  82256. * @returns The selected variant name(s).
  82257. */
  82258. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82259. private static _GetExtensionMetadata;
  82260. /** @hidden */
  82261. onLoading(): void;
  82262. /** @hidden */
  82263. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82264. }
  82265. }
  82266. declare module BABYLON.GLTF2.Loader.Extensions {
  82267. /**
  82268. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82269. * !!! Experimental Extension Subject to Changes !!!
  82270. */
  82271. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82272. /**
  82273. * The name of this extension.
  82274. */
  82275. readonly name: string;
  82276. /**
  82277. * Defines whether this extension is enabled.
  82278. */
  82279. enabled: boolean;
  82280. /**
  82281. * Defines a number that determines the order the extensions are applied.
  82282. */
  82283. order: number;
  82284. private _loader;
  82285. /** @hidden */
  82286. constructor(loader: GLTFLoader);
  82287. /** @hidden */
  82288. dispose(): void;
  82289. /** @hidden */
  82290. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82291. private _loadTransparentPropertiesAsync;
  82292. }
  82293. }
  82294. declare module BABYLON.GLTF2.Loader.Extensions {
  82295. /**
  82296. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82297. */
  82298. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82299. /**
  82300. * The name of this extension.
  82301. */
  82302. readonly name: string;
  82303. /**
  82304. * Defines whether this extension is enabled.
  82305. */
  82306. enabled: boolean;
  82307. /** @hidden */
  82308. constructor(loader: GLTFLoader);
  82309. /** @hidden */
  82310. dispose(): void;
  82311. }
  82312. }
  82313. declare module BABYLON.GLTF2.Loader.Extensions {
  82314. /**
  82315. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82316. * !!! Experimental Extension Subject to Changes !!!
  82317. */
  82318. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82319. /** The name of this extension. */
  82320. readonly name: string;
  82321. /** Defines whether this extension is enabled. */
  82322. enabled: boolean;
  82323. private _loader;
  82324. /** @hidden */
  82325. constructor(loader: GLTFLoader);
  82326. /** @hidden */
  82327. dispose(): void;
  82328. /** @hidden */
  82329. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82330. }
  82331. }
  82332. declare module BABYLON.GLTF2.Loader.Extensions {
  82333. /**
  82334. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82335. */
  82336. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82337. /**
  82338. * The name of this extension.
  82339. */
  82340. readonly name: string;
  82341. /**
  82342. * Defines whether this extension is enabled.
  82343. */
  82344. enabled: boolean;
  82345. private _loader;
  82346. /** @hidden */
  82347. constructor(loader: GLTFLoader);
  82348. /** @hidden */
  82349. dispose(): void;
  82350. /** @hidden */
  82351. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82352. }
  82353. }
  82354. declare module BABYLON.GLTF2.Loader.Extensions {
  82355. /**
  82356. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82357. * !!! Experimental Extension Subject to Changes !!!
  82358. */
  82359. export class KHR_xmp implements IGLTFLoaderExtension {
  82360. /**
  82361. * The name of this extension.
  82362. */
  82363. readonly name: string;
  82364. /**
  82365. * Defines whether this extension is enabled.
  82366. */
  82367. enabled: boolean;
  82368. /**
  82369. * Defines a number that determines the order the extensions are applied.
  82370. */
  82371. order: number;
  82372. private _loader;
  82373. /** @hidden */
  82374. constructor(loader: GLTFLoader);
  82375. /** @hidden */
  82376. dispose(): void;
  82377. /**
  82378. * Called after the loader state changes to LOADING.
  82379. */
  82380. onLoading(): void;
  82381. }
  82382. }
  82383. declare module BABYLON.GLTF2.Loader.Extensions {
  82384. /**
  82385. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82386. */
  82387. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82388. /**
  82389. * The name of this extension.
  82390. */
  82391. readonly name: string;
  82392. /**
  82393. * Defines whether this extension is enabled.
  82394. */
  82395. enabled: boolean;
  82396. private _loader;
  82397. private _clips;
  82398. private _emitters;
  82399. /** @hidden */
  82400. constructor(loader: GLTFLoader);
  82401. /** @hidden */
  82402. dispose(): void;
  82403. /** @hidden */
  82404. onLoading(): void;
  82405. /** @hidden */
  82406. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82407. /** @hidden */
  82408. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82409. /** @hidden */
  82410. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82411. private _loadClipAsync;
  82412. private _loadEmitterAsync;
  82413. private _getEventAction;
  82414. private _loadAnimationEventAsync;
  82415. }
  82416. }
  82417. declare module BABYLON.GLTF2.Loader.Extensions {
  82418. /**
  82419. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82420. */
  82421. export class MSFT_lod implements IGLTFLoaderExtension {
  82422. /**
  82423. * The name of this extension.
  82424. */
  82425. readonly name: string;
  82426. /**
  82427. * Defines whether this extension is enabled.
  82428. */
  82429. enabled: boolean;
  82430. /**
  82431. * Defines a number that determines the order the extensions are applied.
  82432. */
  82433. order: number;
  82434. /**
  82435. * Maximum number of LODs to load, starting from the lowest LOD.
  82436. */
  82437. maxLODsToLoad: number;
  82438. /**
  82439. * Observable raised when all node LODs of one level are loaded.
  82440. * The event data is the index of the loaded LOD starting from zero.
  82441. * Dispose the loader to cancel the loading of the next level of LODs.
  82442. */
  82443. onNodeLODsLoadedObservable: Observable<number>;
  82444. /**
  82445. * Observable raised when all material LODs of one level are loaded.
  82446. * The event data is the index of the loaded LOD starting from zero.
  82447. * Dispose the loader to cancel the loading of the next level of LODs.
  82448. */
  82449. onMaterialLODsLoadedObservable: Observable<number>;
  82450. private _loader;
  82451. private _bufferLODs;
  82452. private _nodeIndexLOD;
  82453. private _nodeSignalLODs;
  82454. private _nodePromiseLODs;
  82455. private _nodeBufferLODs;
  82456. private _materialIndexLOD;
  82457. private _materialSignalLODs;
  82458. private _materialPromiseLODs;
  82459. private _materialBufferLODs;
  82460. /** @hidden */
  82461. constructor(loader: GLTFLoader);
  82462. /** @hidden */
  82463. dispose(): void;
  82464. /** @hidden */
  82465. onReady(): void;
  82466. /** @hidden */
  82467. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82468. /** @hidden */
  82469. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82470. /** @hidden */
  82471. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82472. /** @hidden */
  82473. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82474. /** @hidden */
  82475. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82476. private _loadBufferLOD;
  82477. /**
  82478. * Gets an array of LOD properties from lowest to highest.
  82479. */
  82480. private _getLODs;
  82481. private _disposeTransformNode;
  82482. private _disposeMaterials;
  82483. }
  82484. }
  82485. declare module BABYLON.GLTF2.Loader.Extensions {
  82486. /** @hidden */
  82487. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82488. readonly name: string;
  82489. enabled: boolean;
  82490. private _loader;
  82491. constructor(loader: GLTFLoader);
  82492. dispose(): void;
  82493. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82494. }
  82495. }
  82496. declare module BABYLON.GLTF2.Loader.Extensions {
  82497. /** @hidden */
  82498. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82499. readonly name: string;
  82500. enabled: boolean;
  82501. private _loader;
  82502. constructor(loader: GLTFLoader);
  82503. dispose(): void;
  82504. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82505. }
  82506. }
  82507. declare module BABYLON.GLTF2.Loader.Extensions {
  82508. /**
  82509. * Store glTF extras (if present) in BJS objects' metadata
  82510. */
  82511. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82512. /**
  82513. * The name of this extension.
  82514. */
  82515. readonly name: string;
  82516. /**
  82517. * Defines whether this extension is enabled.
  82518. */
  82519. enabled: boolean;
  82520. private _loader;
  82521. private _assignExtras;
  82522. /** @hidden */
  82523. constructor(loader: GLTFLoader);
  82524. /** @hidden */
  82525. dispose(): void;
  82526. /** @hidden */
  82527. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82528. /** @hidden */
  82529. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82530. /** @hidden */
  82531. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82532. }
  82533. }
  82534. declare module BABYLON {
  82535. /**
  82536. * Class reading and parsing the MTL file bundled with the obj file.
  82537. */
  82538. export class MTLFileLoader {
  82539. /**
  82540. * Invert Y-Axis of referenced textures on load
  82541. */
  82542. static INVERT_TEXTURE_Y: boolean;
  82543. /**
  82544. * All material loaded from the mtl will be set here
  82545. */
  82546. materials: StandardMaterial[];
  82547. /**
  82548. * This function will read the mtl file and create each material described inside
  82549. * This function could be improve by adding :
  82550. * -some component missing (Ni, Tf...)
  82551. * -including the specific options available
  82552. *
  82553. * @param scene defines the scene the material will be created in
  82554. * @param data defines the mtl data to parse
  82555. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82556. * @param forAssetContainer defines if the material should be registered in the scene
  82557. */
  82558. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82559. /**
  82560. * Gets the texture for the material.
  82561. *
  82562. * If the material is imported from input file,
  82563. * We sanitize the url to ensure it takes the textre from aside the material.
  82564. *
  82565. * @param rootUrl The root url to load from
  82566. * @param value The value stored in the mtl
  82567. * @return The Texture
  82568. */
  82569. private static _getTexture;
  82570. }
  82571. }
  82572. declare module BABYLON {
  82573. /**
  82574. * Options for loading OBJ/MTL files
  82575. */
  82576. type MeshLoadOptions = {
  82577. /**
  82578. * Defines if UVs are optimized by default during load.
  82579. */
  82580. OptimizeWithUV: boolean;
  82581. /**
  82582. * Defines custom scaling of UV coordinates of loaded meshes.
  82583. */
  82584. UVScaling: Vector2;
  82585. /**
  82586. * Invert model on y-axis (does a model scaling inversion)
  82587. */
  82588. InvertY: boolean;
  82589. /**
  82590. * Invert Y-Axis of referenced textures on load
  82591. */
  82592. InvertTextureY: boolean;
  82593. /**
  82594. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82595. */
  82596. ImportVertexColors: boolean;
  82597. /**
  82598. * Compute the normals for the model, even if normals are present in the file.
  82599. */
  82600. ComputeNormals: boolean;
  82601. /**
  82602. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82603. */
  82604. SkipMaterials: boolean;
  82605. /**
  82606. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82607. */
  82608. MaterialLoadingFailsSilently: boolean;
  82609. };
  82610. /**
  82611. * OBJ file type loader.
  82612. * This is a babylon scene loader plugin.
  82613. */
  82614. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82615. /**
  82616. * Defines if UVs are optimized by default during load.
  82617. */
  82618. static OPTIMIZE_WITH_UV: boolean;
  82619. /**
  82620. * Invert model on y-axis (does a model scaling inversion)
  82621. */
  82622. static INVERT_Y: boolean;
  82623. /**
  82624. * Invert Y-Axis of referenced textures on load
  82625. */
  82626. static get INVERT_TEXTURE_Y(): boolean;
  82627. static set INVERT_TEXTURE_Y(value: boolean);
  82628. /**
  82629. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82630. */
  82631. static IMPORT_VERTEX_COLORS: boolean;
  82632. /**
  82633. * Compute the normals for the model, even if normals are present in the file.
  82634. */
  82635. static COMPUTE_NORMALS: boolean;
  82636. /**
  82637. * Defines custom scaling of UV coordinates of loaded meshes.
  82638. */
  82639. static UV_SCALING: Vector2;
  82640. /**
  82641. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82642. */
  82643. static SKIP_MATERIALS: boolean;
  82644. /**
  82645. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82646. *
  82647. * Defaults to true for backwards compatibility.
  82648. */
  82649. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82650. /**
  82651. * Defines the name of the plugin.
  82652. */
  82653. name: string;
  82654. /**
  82655. * Defines the extension the plugin is able to load.
  82656. */
  82657. extensions: string;
  82658. /** @hidden */
  82659. obj: RegExp;
  82660. /** @hidden */
  82661. group: RegExp;
  82662. /** @hidden */
  82663. mtllib: RegExp;
  82664. /** @hidden */
  82665. usemtl: RegExp;
  82666. /** @hidden */
  82667. smooth: RegExp;
  82668. /** @hidden */
  82669. vertexPattern: RegExp;
  82670. /** @hidden */
  82671. normalPattern: RegExp;
  82672. /** @hidden */
  82673. uvPattern: RegExp;
  82674. /** @hidden */
  82675. facePattern1: RegExp;
  82676. /** @hidden */
  82677. facePattern2: RegExp;
  82678. /** @hidden */
  82679. facePattern3: RegExp;
  82680. /** @hidden */
  82681. facePattern4: RegExp;
  82682. /** @hidden */
  82683. facePattern5: RegExp;
  82684. private _forAssetContainer;
  82685. private _meshLoadOptions;
  82686. /**
  82687. * Creates loader for .OBJ files
  82688. *
  82689. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82690. */
  82691. constructor(meshLoadOptions?: MeshLoadOptions);
  82692. private static get currentMeshLoadOptions();
  82693. /**
  82694. * Calls synchronously the MTL file attached to this obj.
  82695. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82696. * Without this function materials are not displayed in the first frame (but displayed after).
  82697. * In consequence it is impossible to get material information in your HTML file
  82698. *
  82699. * @param url The URL of the MTL file
  82700. * @param rootUrl
  82701. * @param onSuccess Callback function to be called when the MTL file is loaded
  82702. * @private
  82703. */
  82704. private _loadMTL;
  82705. /**
  82706. * Instantiates a OBJ file loader plugin.
  82707. * @returns the created plugin
  82708. */
  82709. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82710. /**
  82711. * If the data string can be loaded directly.
  82712. *
  82713. * @param data string containing the file data
  82714. * @returns if the data can be loaded directly
  82715. */
  82716. canDirectLoad(data: string): boolean;
  82717. /**
  82718. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82719. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82720. * @param scene the scene the meshes should be added to
  82721. * @param data the OBJ data to load
  82722. * @param rootUrl root url to load from
  82723. * @param onProgress event that fires when loading progress has occured
  82724. * @param fileName Defines the name of the file to load
  82725. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82726. */
  82727. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82728. meshes: AbstractMesh[];
  82729. particleSystems: IParticleSystem[];
  82730. skeletons: Skeleton[];
  82731. animationGroups: AnimationGroup[];
  82732. }>;
  82733. /**
  82734. * Imports all objects from the loaded OBJ data and adds them to the scene
  82735. * @param scene the scene the objects should be added to
  82736. * @param data the OBJ data to load
  82737. * @param rootUrl root url to load from
  82738. * @param onProgress event that fires when loading progress has occured
  82739. * @param fileName Defines the name of the file to load
  82740. * @returns a promise which completes when objects have been loaded to the scene
  82741. */
  82742. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82743. /**
  82744. * Load into an asset container.
  82745. * @param scene The scene to load into
  82746. * @param data The data to import
  82747. * @param rootUrl The root url for scene and resources
  82748. * @param onProgress The callback when the load progresses
  82749. * @param fileName Defines the name of the file to load
  82750. * @returns The loaded asset container
  82751. */
  82752. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82753. /**
  82754. * Read the OBJ file and create an Array of meshes.
  82755. * Each mesh contains all information given by the OBJ and the MTL file.
  82756. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82757. *
  82758. * @param meshesNames
  82759. * @param scene Scene The scene where are displayed the data
  82760. * @param data String The content of the obj file
  82761. * @param rootUrl String The path to the folder
  82762. * @returns Array<AbstractMesh>
  82763. * @private
  82764. */
  82765. private _parseSolid;
  82766. }
  82767. }
  82768. declare module BABYLON {
  82769. /**
  82770. * STL file type loader.
  82771. * This is a babylon scene loader plugin.
  82772. */
  82773. export class STLFileLoader implements ISceneLoaderPlugin {
  82774. /** @hidden */
  82775. solidPattern: RegExp;
  82776. /** @hidden */
  82777. facetsPattern: RegExp;
  82778. /** @hidden */
  82779. normalPattern: RegExp;
  82780. /** @hidden */
  82781. vertexPattern: RegExp;
  82782. /**
  82783. * Defines the name of the plugin.
  82784. */
  82785. name: string;
  82786. /**
  82787. * Defines the extensions the stl loader is able to load.
  82788. * force data to come in as an ArrayBuffer
  82789. * we'll convert to string if it looks like it's an ASCII .stl
  82790. */
  82791. extensions: ISceneLoaderPluginExtensions;
  82792. /**
  82793. * Import meshes into a scene.
  82794. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82795. * @param scene The scene to import into
  82796. * @param data The data to import
  82797. * @param rootUrl The root url for scene and resources
  82798. * @param meshes The meshes array to import into
  82799. * @param particleSystems The particle systems array to import into
  82800. * @param skeletons The skeletons array to import into
  82801. * @param onError The callback when import fails
  82802. * @returns True if successful or false otherwise
  82803. */
  82804. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82805. /**
  82806. * Load into a scene.
  82807. * @param scene The scene to load into
  82808. * @param data The data to import
  82809. * @param rootUrl The root url for scene and resources
  82810. * @param onError The callback when import fails
  82811. * @returns true if successful or false otherwise
  82812. */
  82813. load(scene: Scene, data: any, rootUrl: string): boolean;
  82814. /**
  82815. * Load into an asset container.
  82816. * @param scene The scene to load into
  82817. * @param data The data to import
  82818. * @param rootUrl The root url for scene and resources
  82819. * @param onError The callback when import fails
  82820. * @returns The loaded asset container
  82821. */
  82822. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82823. private _isBinary;
  82824. private _parseBinary;
  82825. private _parseASCII;
  82826. }
  82827. }
  82828. declare module BABYLON {
  82829. /**
  82830. * Class for generating OBJ data from a Babylon scene.
  82831. */
  82832. export class OBJExport {
  82833. /**
  82834. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82835. * @param mesh defines the list of meshes to serialize
  82836. * @param materials defines if materials should be exported
  82837. * @param matlibname defines the name of the associated mtl file
  82838. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82839. * @returns the OBJ content
  82840. */
  82841. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82842. /**
  82843. * Exports the material(s) of a mesh in .MTL file format (text)
  82844. * @param mesh defines the mesh to extract the material from
  82845. * @returns the mtl content
  82846. */
  82847. static MTL(mesh: Mesh): string;
  82848. }
  82849. }
  82850. declare module BABYLON {
  82851. /** @hidden */
  82852. export var __IGLTFExporterExtension: number;
  82853. /**
  82854. * Interface for extending the exporter
  82855. * @hidden
  82856. */
  82857. export interface IGLTFExporterExtension {
  82858. /**
  82859. * The name of this extension
  82860. */
  82861. readonly name: string;
  82862. /**
  82863. * Defines whether this extension is enabled
  82864. */
  82865. enabled: boolean;
  82866. /**
  82867. * Defines whether this extension is required
  82868. */
  82869. required: boolean;
  82870. }
  82871. }
  82872. declare module BABYLON.GLTF2.Exporter {
  82873. /** @hidden */
  82874. export var __IGLTFExporterExtensionV2: number;
  82875. /**
  82876. * Interface for a glTF exporter extension
  82877. * @hidden
  82878. */
  82879. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82880. /**
  82881. * Define this method to modify the default behavior before exporting a texture
  82882. * @param context The context when loading the asset
  82883. * @param babylonTexture The Babylon.js texture
  82884. * @param mimeType The mime-type of the generated image
  82885. * @returns A promise that resolves with the exported texture
  82886. */
  82887. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82888. /**
  82889. * Define this method to get notified when a texture info is created
  82890. * @param context The context when loading the asset
  82891. * @param textureInfo The glTF texture info
  82892. * @param babylonTexture The Babylon.js texture
  82893. */
  82894. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82895. /**
  82896. * Define this method to modify the default behavior when exporting texture info
  82897. * @param context The context when loading the asset
  82898. * @param meshPrimitive glTF mesh primitive
  82899. * @param babylonSubMesh Babylon submesh
  82900. * @param binaryWriter glTF serializer binary writer instance
  82901. * @returns nullable IMeshPrimitive promise
  82902. */
  82903. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82904. /**
  82905. * Define this method to modify the default behavior when exporting a node
  82906. * @param context The context when exporting the node
  82907. * @param node glTF node
  82908. * @param babylonNode BabylonJS node
  82909. * @returns nullable INode promise
  82910. */
  82911. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82912. [key: number]: number;
  82913. }): Promise<Nullable<INode>>;
  82914. /**
  82915. * Define this method to modify the default behavior when exporting a material
  82916. * @param material glTF material
  82917. * @param babylonMaterial BabylonJS material
  82918. * @returns nullable IMaterial promise
  82919. */
  82920. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82921. /**
  82922. * Define this method to return additional textures to export from a material
  82923. * @param material glTF material
  82924. * @param babylonMaterial BabylonJS material
  82925. * @returns List of textures
  82926. */
  82927. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82928. /** Gets a boolean indicating that this extension was used */
  82929. wasUsed: boolean;
  82930. /** Gets a boolean indicating that this extension is required for the file to work */
  82931. required: boolean;
  82932. /**
  82933. * Called after the exporter state changes to EXPORTING
  82934. */
  82935. onExporting?(): void;
  82936. }
  82937. }
  82938. declare module BABYLON.GLTF2.Exporter {
  82939. /**
  82940. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82941. * @hidden
  82942. */
  82943. export class _GLTFMaterialExporter {
  82944. /**
  82945. * Represents the dielectric specular values for R, G and B
  82946. */
  82947. private static readonly _DielectricSpecular;
  82948. /**
  82949. * Allows the maximum specular power to be defined for material calculations
  82950. */
  82951. private static readonly _MaxSpecularPower;
  82952. /**
  82953. * Mapping to store textures
  82954. */
  82955. private _textureMap;
  82956. /**
  82957. * Numeric tolerance value
  82958. */
  82959. private static readonly _Epsilon;
  82960. /**
  82961. * Reference to the glTF Exporter
  82962. */
  82963. private _exporter;
  82964. constructor(exporter: _Exporter);
  82965. /**
  82966. * Specifies if two colors are approximately equal in value
  82967. * @param color1 first color to compare to
  82968. * @param color2 second color to compare to
  82969. * @param epsilon threshold value
  82970. */
  82971. private static FuzzyEquals;
  82972. /**
  82973. * Gets the materials from a Babylon scene and converts them to glTF materials
  82974. * @param scene babylonjs scene
  82975. * @param mimeType texture mime type
  82976. * @param images array of images
  82977. * @param textures array of textures
  82978. * @param materials array of materials
  82979. * @param imageData mapping of texture names to base64 textures
  82980. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82981. */
  82982. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82983. /**
  82984. * Makes a copy of the glTF material without the texture parameters
  82985. * @param originalMaterial original glTF material
  82986. * @returns glTF material without texture parameters
  82987. */
  82988. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82989. /**
  82990. * Specifies if the material has any texture parameters present
  82991. * @param material glTF Material
  82992. * @returns boolean specifying if texture parameters are present
  82993. */
  82994. _hasTexturesPresent(material: IMaterial): boolean;
  82995. /**
  82996. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82997. * @param babylonStandardMaterial
  82998. * @returns glTF Metallic Roughness Material representation
  82999. */
  83000. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83001. /**
  83002. * Computes the metallic factor
  83003. * @param diffuse diffused value
  83004. * @param specular specular value
  83005. * @param oneMinusSpecularStrength one minus the specular strength
  83006. * @returns metallic value
  83007. */
  83008. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83009. /**
  83010. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83011. * @param glTFMaterial glTF material
  83012. * @param babylonMaterial Babylon material
  83013. */
  83014. private static _SetAlphaMode;
  83015. /**
  83016. * Converts a Babylon Standard Material to a glTF Material
  83017. * @param babylonStandardMaterial BJS Standard Material
  83018. * @param mimeType mime type to use for the textures
  83019. * @param images array of glTF image interfaces
  83020. * @param textures array of glTF texture interfaces
  83021. * @param materials array of glTF material interfaces
  83022. * @param imageData map of image file name to data
  83023. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83024. */
  83025. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83026. private _finishMaterial;
  83027. /**
  83028. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83029. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83030. * @param mimeType mime type to use for the textures
  83031. * @param images array of glTF image interfaces
  83032. * @param textures array of glTF texture interfaces
  83033. * @param materials array of glTF material interfaces
  83034. * @param imageData map of image file name to data
  83035. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83036. */
  83037. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83038. /**
  83039. * Converts an image typed array buffer to a base64 image
  83040. * @param buffer typed array buffer
  83041. * @param width width of the image
  83042. * @param height height of the image
  83043. * @param mimeType mimetype of the image
  83044. * @returns base64 image string
  83045. */
  83046. private _createBase64FromCanvasAsync;
  83047. /**
  83048. * Generates a white texture based on the specified width and height
  83049. * @param width width of the texture in pixels
  83050. * @param height height of the texture in pixels
  83051. * @param scene babylonjs scene
  83052. * @returns white texture
  83053. */
  83054. private _createWhiteTexture;
  83055. /**
  83056. * 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
  83057. * @param texture1 first texture to resize
  83058. * @param texture2 second texture to resize
  83059. * @param scene babylonjs scene
  83060. * @returns resized textures or null
  83061. */
  83062. private _resizeTexturesToSameDimensions;
  83063. /**
  83064. * Converts an array of pixels to a Float32Array
  83065. * Throws an error if the pixel format is not supported
  83066. * @param pixels - array buffer containing pixel values
  83067. * @returns Float32 of pixels
  83068. */
  83069. private _convertPixelArrayToFloat32;
  83070. /**
  83071. * Convert Specular Glossiness Textures to Metallic Roughness
  83072. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83073. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83074. * @param diffuseTexture texture used to store diffuse information
  83075. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83076. * @param factors specular glossiness material factors
  83077. * @param mimeType the mime type to use for the texture
  83078. * @returns pbr metallic roughness interface or null
  83079. */
  83080. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83081. /**
  83082. * Converts specular glossiness material properties to metallic roughness
  83083. * @param specularGlossiness interface with specular glossiness material properties
  83084. * @returns interface with metallic roughness material properties
  83085. */
  83086. private _convertSpecularGlossinessToMetallicRoughness;
  83087. /**
  83088. * Calculates the surface reflectance, independent of lighting conditions
  83089. * @param color Color source to calculate brightness from
  83090. * @returns number representing the perceived brightness, or zero if color is undefined
  83091. */
  83092. private _getPerceivedBrightness;
  83093. /**
  83094. * Returns the maximum color component value
  83095. * @param color
  83096. * @returns maximum color component value, or zero if color is null or undefined
  83097. */
  83098. private _getMaxComponent;
  83099. /**
  83100. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83101. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83102. * @param mimeType mime type to use for the textures
  83103. * @param images array of glTF image interfaces
  83104. * @param textures array of glTF texture interfaces
  83105. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83106. * @param imageData map of image file name to data
  83107. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83108. * @returns glTF PBR Metallic Roughness factors
  83109. */
  83110. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83111. private _getGLTFTextureSampler;
  83112. private _getGLTFTextureWrapMode;
  83113. private _getGLTFTextureWrapModesSampler;
  83114. /**
  83115. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83116. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83117. * @param mimeType mime type to use for the textures
  83118. * @param images array of glTF image interfaces
  83119. * @param textures array of glTF texture interfaces
  83120. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83121. * @param imageData map of image file name to data
  83122. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83123. * @returns glTF PBR Metallic Roughness factors
  83124. */
  83125. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83126. /**
  83127. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83128. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83129. * @param mimeType mime type to use for the textures
  83130. * @param images array of glTF image interfaces
  83131. * @param textures array of glTF texture interfaces
  83132. * @param materials array of glTF material interfaces
  83133. * @param imageData map of image file name to data
  83134. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83135. */
  83136. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83137. private setMetallicRoughnessPbrMaterial;
  83138. private getPixelsFromTexture;
  83139. /**
  83140. * Extracts a texture from a Babylon texture into file data and glTF data
  83141. * @param babylonTexture Babylon texture to extract
  83142. * @param mimeType Mime Type of the babylonTexture
  83143. * @return glTF texture info, or null if the texture format is not supported
  83144. */
  83145. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83146. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83147. /**
  83148. * Builds a texture from base64 string
  83149. * @param base64Texture base64 texture string
  83150. * @param baseTextureName Name to use for the texture
  83151. * @param mimeType image mime type for the texture
  83152. * @param images array of images
  83153. * @param textures array of textures
  83154. * @param imageData map of image data
  83155. * @returns glTF texture info, or null if the texture format is not supported
  83156. */
  83157. private _getTextureInfoFromBase64;
  83158. }
  83159. }
  83160. declare module BABYLON {
  83161. /**
  83162. * Class for holding and downloading glTF file data
  83163. */
  83164. export class GLTFData {
  83165. /**
  83166. * Object which contains the file name as the key and its data as the value
  83167. */
  83168. glTFFiles: {
  83169. [fileName: string]: string | Blob;
  83170. };
  83171. /**
  83172. * Initializes the glTF file object
  83173. */
  83174. constructor();
  83175. /**
  83176. * Downloads the glTF data as files based on their names and data
  83177. */
  83178. downloadFiles(): void;
  83179. }
  83180. }
  83181. declare module BABYLON {
  83182. /**
  83183. * Holds a collection of exporter options and parameters
  83184. */
  83185. export interface IExportOptions {
  83186. /**
  83187. * Function which indicates whether a babylon node should be exported or not
  83188. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83189. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83190. */
  83191. shouldExportNode?(node: Node): boolean;
  83192. /**
  83193. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83194. * @param metadata source metadata to read from
  83195. * @returns the data to store to glTF node extras
  83196. */
  83197. metadataSelector?(metadata: any): any;
  83198. /**
  83199. * The sample rate to bake animation curves
  83200. */
  83201. animationSampleRate?: number;
  83202. /**
  83203. * Begin serialization without waiting for the scene to be ready
  83204. */
  83205. exportWithoutWaitingForScene?: boolean;
  83206. /**
  83207. * Indicates if coordinate system swapping root nodes should be included in export
  83208. */
  83209. includeCoordinateSystemConversionNodes?: boolean;
  83210. }
  83211. /**
  83212. * Class for generating glTF data from a Babylon scene.
  83213. */
  83214. export class GLTF2Export {
  83215. /**
  83216. * Exports the geometry of the scene to .gltf file format asynchronously
  83217. * @param scene Babylon scene with scene hierarchy information
  83218. * @param filePrefix File prefix to use when generating the glTF file
  83219. * @param options Exporter options
  83220. * @returns Returns an object with a .gltf file and associates texture names
  83221. * as keys and their data and paths as values
  83222. */
  83223. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83224. private static _PreExportAsync;
  83225. private static _PostExportAsync;
  83226. /**
  83227. * Exports the geometry of the scene to .glb file format asychronously
  83228. * @param scene Babylon scene with scene hierarchy information
  83229. * @param filePrefix File prefix to use when generating glb file
  83230. * @param options Exporter options
  83231. * @returns Returns an object with a .glb filename as key and data as value
  83232. */
  83233. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83234. }
  83235. }
  83236. declare module BABYLON.GLTF2.Exporter {
  83237. /**
  83238. * @hidden
  83239. */
  83240. export class _GLTFUtilities {
  83241. /**
  83242. * Creates a buffer view based on the supplied arguments
  83243. * @param bufferIndex index value of the specified buffer
  83244. * @param byteOffset byte offset value
  83245. * @param byteLength byte length of the bufferView
  83246. * @param byteStride byte distance between conequential elements
  83247. * @param name name of the buffer view
  83248. * @returns bufferView for glTF
  83249. */
  83250. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83251. /**
  83252. * Creates an accessor based on the supplied arguments
  83253. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83254. * @param name The name of the accessor
  83255. * @param type The type of the accessor
  83256. * @param componentType The datatype of components in the attribute
  83257. * @param count The number of attributes referenced by this accessor
  83258. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83259. * @param min Minimum value of each component in this attribute
  83260. * @param max Maximum value of each component in this attribute
  83261. * @returns accessor for glTF
  83262. */
  83263. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83264. /**
  83265. * Calculates the minimum and maximum values of an array of position floats
  83266. * @param positions Positions array of a mesh
  83267. * @param vertexStart Starting vertex offset to calculate min and max values
  83268. * @param vertexCount Number of vertices to check for min and max values
  83269. * @returns min number array and max number array
  83270. */
  83271. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83272. min: number[];
  83273. max: number[];
  83274. };
  83275. /**
  83276. * Converts a new right-handed Vector3
  83277. * @param vector vector3 array
  83278. * @returns right-handed Vector3
  83279. */
  83280. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83281. /**
  83282. * Converts a Vector3 to right-handed
  83283. * @param vector Vector3 to convert to right-handed
  83284. */
  83285. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83286. /**
  83287. * Converts a three element number array to right-handed
  83288. * @param vector number array to convert to right-handed
  83289. */
  83290. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83291. /**
  83292. * Converts a new right-handed Vector3
  83293. * @param vector vector3 array
  83294. * @returns right-handed Vector3
  83295. */
  83296. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83297. /**
  83298. * Converts a Vector3 to right-handed
  83299. * @param vector Vector3 to convert to right-handed
  83300. */
  83301. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83302. /**
  83303. * Converts a three element number array to right-handed
  83304. * @param vector number array to convert to right-handed
  83305. */
  83306. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83307. /**
  83308. * Converts a Vector4 to right-handed
  83309. * @param vector Vector4 to convert to right-handed
  83310. */
  83311. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83312. /**
  83313. * Converts a Vector4 to right-handed
  83314. * @param vector Vector4 to convert to right-handed
  83315. */
  83316. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83317. /**
  83318. * Converts a Quaternion to right-handed
  83319. * @param quaternion Source quaternion to convert to right-handed
  83320. */
  83321. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83322. /**
  83323. * Converts a Quaternion to right-handed
  83324. * @param quaternion Source quaternion to convert to right-handed
  83325. */
  83326. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83327. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83328. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83329. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83330. }
  83331. }
  83332. declare module BABYLON.GLTF2.Exporter {
  83333. /**
  83334. * Converts Babylon Scene into glTF 2.0.
  83335. * @hidden
  83336. */
  83337. export class _Exporter {
  83338. /**
  83339. * Stores the glTF to export
  83340. */
  83341. _glTF: IGLTF;
  83342. /**
  83343. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83344. */
  83345. _bufferViews: IBufferView[];
  83346. /**
  83347. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83348. */
  83349. _accessors: IAccessor[];
  83350. /**
  83351. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83352. */
  83353. _nodes: INode[];
  83354. /**
  83355. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83356. */
  83357. private _scenes;
  83358. /**
  83359. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83360. */
  83361. private _meshes;
  83362. /**
  83363. * Stores all the generated material information, which represents the appearance of each primitive
  83364. */
  83365. _materials: IMaterial[];
  83366. _materialMap: {
  83367. [materialID: number]: number;
  83368. };
  83369. /**
  83370. * Stores all the generated texture information, which is referenced by glTF materials
  83371. */
  83372. _textures: ITexture[];
  83373. /**
  83374. * Stores all the generated image information, which is referenced by glTF textures
  83375. */
  83376. _images: IImage[];
  83377. /**
  83378. * Stores all the texture samplers
  83379. */
  83380. _samplers: ISampler[];
  83381. /**
  83382. * Stores all the generated glTF skins
  83383. */
  83384. _skins: ISkin[];
  83385. /**
  83386. * Stores all the generated animation samplers, which is referenced by glTF animations
  83387. */
  83388. /**
  83389. * Stores the animations for glTF models
  83390. */
  83391. private _animations;
  83392. /**
  83393. * Stores the total amount of bytes stored in the glTF buffer
  83394. */
  83395. private _totalByteLength;
  83396. /**
  83397. * Stores a reference to the Babylon scene containing the source geometry and material information
  83398. */
  83399. _babylonScene: Scene;
  83400. /**
  83401. * Stores a map of the image data, where the key is the file name and the value
  83402. * is the image data
  83403. */
  83404. _imageData: {
  83405. [fileName: string]: {
  83406. data: Uint8Array;
  83407. mimeType: ImageMimeType;
  83408. };
  83409. };
  83410. protected _orderedImageData: Array<{
  83411. data: Uint8Array;
  83412. mimeType: ImageMimeType;
  83413. }>;
  83414. /**
  83415. * Stores a map of the unique id of a node to its index in the node array
  83416. */
  83417. _nodeMap: {
  83418. [key: number]: number;
  83419. };
  83420. /**
  83421. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83422. */
  83423. _convertToRightHandedSystem: boolean;
  83424. /**
  83425. * Specifies if a Babylon node should be converted to right-handed on export
  83426. */
  83427. _convertToRightHandedSystemMap: {
  83428. [nodeId: number]: boolean;
  83429. };
  83430. _includeCoordinateSystemConversionNodes: boolean;
  83431. /**
  83432. * Baked animation sample rate
  83433. */
  83434. private _animationSampleRate;
  83435. private _options;
  83436. private _localEngine;
  83437. _glTFMaterialExporter: _GLTFMaterialExporter;
  83438. private _extensions;
  83439. private static _ExtensionNames;
  83440. private static _ExtensionFactories;
  83441. private _applyExtension;
  83442. private _applyExtensions;
  83443. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83444. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83445. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83446. [key: number]: number;
  83447. }): Promise<Nullable<INode>>;
  83448. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83449. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83450. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83451. private _forEachExtensions;
  83452. private _extensionsOnExporting;
  83453. /**
  83454. * Load glTF serializer extensions
  83455. */
  83456. private _loadExtensions;
  83457. /**
  83458. * Creates a glTF Exporter instance, which can accept optional exporter options
  83459. * @param babylonScene Babylon scene object
  83460. * @param options Options to modify the behavior of the exporter
  83461. */
  83462. constructor(babylonScene: Scene, options?: IExportOptions);
  83463. dispose(): void;
  83464. /**
  83465. * Registers a glTF exporter extension
  83466. * @param name Name of the extension to export
  83467. * @param factory The factory function that creates the exporter extension
  83468. */
  83469. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83470. /**
  83471. * Un-registers an exporter extension
  83472. * @param name The name fo the exporter extension
  83473. * @returns A boolean indicating whether the extension has been un-registered
  83474. */
  83475. static UnregisterExtension(name: string): boolean;
  83476. /**
  83477. * Lazy load a local engine
  83478. */
  83479. _getLocalEngine(): Engine;
  83480. private reorderIndicesBasedOnPrimitiveMode;
  83481. /**
  83482. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83483. * clock-wise during export to glTF
  83484. * @param submesh BabylonJS submesh
  83485. * @param primitiveMode Primitive mode of the mesh
  83486. * @param sideOrientation the winding order of the submesh
  83487. * @param vertexBufferKind The type of vertex attribute
  83488. * @param meshAttributeArray The vertex attribute data
  83489. * @param byteOffset The offset to the binary data
  83490. * @param binaryWriter The binary data for the glTF file
  83491. * @param convertToRightHandedSystem Converts the values to right-handed
  83492. */
  83493. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83494. /**
  83495. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83496. * clock-wise during export to glTF
  83497. * @param submesh BabylonJS submesh
  83498. * @param primitiveMode Primitive mode of the mesh
  83499. * @param sideOrientation the winding order of the submesh
  83500. * @param vertexBufferKind The type of vertex attribute
  83501. * @param meshAttributeArray The vertex attribute data
  83502. * @param byteOffset The offset to the binary data
  83503. * @param binaryWriter The binary data for the glTF file
  83504. * @param convertToRightHandedSystem Converts the values to right-handed
  83505. */
  83506. private reorderTriangleFillMode;
  83507. /**
  83508. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83509. * clock-wise during export to glTF
  83510. * @param submesh BabylonJS submesh
  83511. * @param primitiveMode Primitive mode of the mesh
  83512. * @param sideOrientation the winding order of the submesh
  83513. * @param vertexBufferKind The type of vertex attribute
  83514. * @param meshAttributeArray The vertex attribute data
  83515. * @param byteOffset The offset to the binary data
  83516. * @param binaryWriter The binary data for the glTF file
  83517. * @param convertToRightHandedSystem Converts the values to right-handed
  83518. */
  83519. private reorderTriangleStripDrawMode;
  83520. /**
  83521. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83522. * clock-wise during export to glTF
  83523. * @param submesh BabylonJS submesh
  83524. * @param primitiveMode Primitive mode of the mesh
  83525. * @param sideOrientation the winding order of the submesh
  83526. * @param vertexBufferKind The type of vertex attribute
  83527. * @param meshAttributeArray The vertex attribute data
  83528. * @param byteOffset The offset to the binary data
  83529. * @param binaryWriter The binary data for the glTF file
  83530. * @param convertToRightHandedSystem Converts the values to right-handed
  83531. */
  83532. private reorderTriangleFanMode;
  83533. /**
  83534. * Writes the vertex attribute data to binary
  83535. * @param vertices The vertices to write to the binary writer
  83536. * @param byteOffset The offset into the binary writer to overwrite binary data
  83537. * @param vertexAttributeKind The vertex attribute type
  83538. * @param meshAttributeArray The vertex attribute data
  83539. * @param binaryWriter The writer containing the binary data
  83540. * @param convertToRightHandedSystem Converts the values to right-handed
  83541. */
  83542. private writeVertexAttributeData;
  83543. /**
  83544. * Writes mesh attribute data to a data buffer
  83545. * Returns the bytelength of the data
  83546. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83547. * @param meshAttributeArray Array containing the attribute data
  83548. * @param byteStride Specifies the space between data
  83549. * @param binaryWriter The buffer to write the binary data to
  83550. * @param convertToRightHandedSystem Converts the values to right-handed
  83551. */
  83552. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83553. /**
  83554. * Writes mesh attribute data to a data buffer
  83555. * Returns the bytelength of the data
  83556. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83557. * @param meshAttributeArray Array containing the attribute data
  83558. * @param byteStride Specifies the space between data
  83559. * @param binaryWriter The buffer to write the binary data to
  83560. * @param convertToRightHandedSystem Converts the values to right-handed
  83561. */
  83562. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  83563. /**
  83564. * Generates glTF json data
  83565. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83566. * @param glTFPrefix Text to use when prefixing a glTF file
  83567. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83568. * @returns json data as string
  83569. */
  83570. private generateJSON;
  83571. /**
  83572. * Generates data for .gltf and .bin files based on the glTF prefix string
  83573. * @param glTFPrefix Text to use when prefixing a glTF file
  83574. * @param dispose Dispose the exporter
  83575. * @returns GLTFData with glTF file data
  83576. */
  83577. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83578. /**
  83579. * Creates a binary buffer for glTF
  83580. * @returns array buffer for binary data
  83581. */
  83582. private _generateBinaryAsync;
  83583. /**
  83584. * Pads the number to a multiple of 4
  83585. * @param num number to pad
  83586. * @returns padded number
  83587. */
  83588. private _getPadding;
  83589. /**
  83590. * @hidden
  83591. */
  83592. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83593. /**
  83594. * Sets the TRS for each node
  83595. * @param node glTF Node for storing the transformation data
  83596. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83597. * @param convertToRightHandedSystem Converts the values to right-handed
  83598. */
  83599. private setNodeTransformation;
  83600. private getVertexBufferFromMesh;
  83601. /**
  83602. * Creates a bufferview based on the vertices type for the Babylon mesh
  83603. * @param kind Indicates the type of vertices data
  83604. * @param componentType Indicates the numerical type used to store the data
  83605. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83606. * @param binaryWriter The buffer to write the bufferview data to
  83607. * @param convertToRightHandedSystem Converts the values to right-handed
  83608. */
  83609. private createBufferViewKind;
  83610. /**
  83611. * Creates a bufferview based on the vertices type for the Babylon mesh
  83612. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  83613. * @param babylonMorphTarget the morph target to be exported
  83614. * @param binaryWriter The buffer to write the bufferview data to
  83615. * @param convertToRightHandedSystem Converts the values to right-handed
  83616. */
  83617. private setMorphTargetAttributes;
  83618. /**
  83619. * The primitive mode of the Babylon mesh
  83620. * @param babylonMesh The BabylonJS mesh
  83621. */
  83622. private getMeshPrimitiveMode;
  83623. /**
  83624. * Sets the primitive mode of the glTF mesh primitive
  83625. * @param meshPrimitive glTF mesh primitive
  83626. * @param primitiveMode The primitive mode
  83627. */
  83628. private setPrimitiveMode;
  83629. /**
  83630. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83631. * @param meshPrimitive glTF mesh primitive
  83632. * @param attributeKind vertex attribute
  83633. * @returns boolean specifying if uv coordinates are present
  83634. */
  83635. private setAttributeKind;
  83636. /**
  83637. * Sets data for the primitive attributes of each submesh
  83638. * @param mesh glTF Mesh object to store the primitive attribute information
  83639. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83640. * @param binaryWriter Buffer to write the attribute data to
  83641. * @param convertToRightHandedSystem Converts the values to right-handed
  83642. */
  83643. private setPrimitiveAttributesAsync;
  83644. /**
  83645. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83646. * @param node The node to check
  83647. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83648. */
  83649. private isBabylonCoordinateSystemConvertingNode;
  83650. /**
  83651. * Creates a glTF scene based on the array of meshes
  83652. * Returns the the total byte offset
  83653. * @param babylonScene Babylon scene to get the mesh data from
  83654. * @param binaryWriter Buffer to write binary data to
  83655. */
  83656. private createSceneAsync;
  83657. /**
  83658. * Creates a mapping of Node unique id to node index and handles animations
  83659. * @param babylonScene Babylon Scene
  83660. * @param nodes Babylon transform nodes
  83661. * @param binaryWriter Buffer to write binary data to
  83662. * @returns Node mapping of unique id to index
  83663. */
  83664. private createNodeMapAndAnimationsAsync;
  83665. /**
  83666. * Creates a glTF node from a Babylon mesh
  83667. * @param babylonMesh Source Babylon mesh
  83668. * @param binaryWriter Buffer for storing geometry data
  83669. * @param convertToRightHandedSystem Converts the values to right-handed
  83670. * @param nodeMap Node mapping of unique id to glTF node index
  83671. * @returns glTF node
  83672. */
  83673. private createNodeAsync;
  83674. /**
  83675. * Creates a glTF skin from a Babylon skeleton
  83676. * @param babylonScene Babylon Scene
  83677. * @param nodes Babylon transform nodes
  83678. * @param binaryWriter Buffer to write binary data to
  83679. * @returns Node mapping of unique id to index
  83680. */
  83681. private createSkinsAsync;
  83682. }
  83683. /**
  83684. * @hidden
  83685. *
  83686. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83687. */
  83688. export class _BinaryWriter {
  83689. /**
  83690. * Array buffer which stores all binary data
  83691. */
  83692. private _arrayBuffer;
  83693. /**
  83694. * View of the array buffer
  83695. */
  83696. private _dataView;
  83697. /**
  83698. * byte offset of data in array buffer
  83699. */
  83700. private _byteOffset;
  83701. /**
  83702. * Initialize binary writer with an initial byte length
  83703. * @param byteLength Initial byte length of the array buffer
  83704. */
  83705. constructor(byteLength: number);
  83706. /**
  83707. * Resize the array buffer to the specified byte length
  83708. * @param byteLength
  83709. */
  83710. private resizeBuffer;
  83711. /**
  83712. * Get an array buffer with the length of the byte offset
  83713. * @returns ArrayBuffer resized to the byte offset
  83714. */
  83715. getArrayBuffer(): ArrayBuffer;
  83716. /**
  83717. * Get the byte offset of the array buffer
  83718. * @returns byte offset
  83719. */
  83720. getByteOffset(): number;
  83721. /**
  83722. * Stores an UInt8 in the array buffer
  83723. * @param entry
  83724. * @param byteOffset If defined, specifies where to set the value as an offset.
  83725. */
  83726. setUInt8(entry: number, byteOffset?: number): void;
  83727. /**
  83728. * Stores an UInt16 in the array buffer
  83729. * @param entry
  83730. * @param byteOffset If defined, specifies where to set the value as an offset.
  83731. */
  83732. setUInt16(entry: number, byteOffset?: number): void;
  83733. /**
  83734. * Gets an UInt32 in the array buffer
  83735. * @param entry
  83736. * @param byteOffset If defined, specifies where to set the value as an offset.
  83737. */
  83738. getUInt32(byteOffset: number): number;
  83739. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83740. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83741. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83742. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83743. /**
  83744. * Stores a Float32 in the array buffer
  83745. * @param entry
  83746. */
  83747. setFloat32(entry: number, byteOffset?: number): void;
  83748. /**
  83749. * Stores an UInt32 in the array buffer
  83750. * @param entry
  83751. * @param byteOffset If defined, specifies where to set the value as an offset.
  83752. */
  83753. setUInt32(entry: number, byteOffset?: number): void;
  83754. }
  83755. }
  83756. declare module BABYLON.GLTF2.Exporter {
  83757. /**
  83758. * @hidden
  83759. * Interface to store animation data.
  83760. */
  83761. export interface _IAnimationData {
  83762. /**
  83763. * Keyframe data.
  83764. */
  83765. inputs: number[];
  83766. /**
  83767. * Value data.
  83768. */
  83769. outputs: number[][];
  83770. /**
  83771. * Animation interpolation data.
  83772. */
  83773. samplerInterpolation: AnimationSamplerInterpolation;
  83774. /**
  83775. * Minimum keyframe value.
  83776. */
  83777. inputsMin: number;
  83778. /**
  83779. * Maximum keyframe value.
  83780. */
  83781. inputsMax: number;
  83782. }
  83783. /**
  83784. * @hidden
  83785. */
  83786. export interface _IAnimationInfo {
  83787. /**
  83788. * The target channel for the animation
  83789. */
  83790. animationChannelTargetPath: AnimationChannelTargetPath;
  83791. /**
  83792. * The glTF accessor type for the data.
  83793. */
  83794. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  83795. /**
  83796. * Specifies if quaternions should be used.
  83797. */
  83798. useQuaternion: boolean;
  83799. }
  83800. /**
  83801. * @hidden
  83802. * Utility class for generating glTF animation data from BabylonJS.
  83803. */
  83804. export class _GLTFAnimation {
  83805. /**
  83806. * @ignore
  83807. *
  83808. * Creates glTF channel animation from BabylonJS animation.
  83809. * @param babylonTransformNode - BabylonJS mesh.
  83810. * @param animation - animation.
  83811. * @param animationChannelTargetPath - The target animation channel.
  83812. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83813. * @param useQuaternion - Specifies if quaternions are used.
  83814. * @returns nullable IAnimationData
  83815. */
  83816. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83817. private static _DeduceAnimationInfo;
  83818. /**
  83819. * @ignore
  83820. * Create node animations from the transform node animations
  83821. * @param babylonNode
  83822. * @param runtimeGLTFAnimation
  83823. * @param idleGLTFAnimations
  83824. * @param nodeMap
  83825. * @param nodes
  83826. * @param binaryWriter
  83827. * @param bufferViews
  83828. * @param accessors
  83829. * @param convertToRightHandedSystem
  83830. * @param animationSampleRate
  83831. */
  83832. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83833. [key: number]: number;
  83834. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83835. /**
  83836. * @ignore
  83837. * Create individual morph animations from the mesh's morph target animation tracks
  83838. * @param babylonNode
  83839. * @param runtimeGLTFAnimation
  83840. * @param idleGLTFAnimations
  83841. * @param nodeMap
  83842. * @param nodes
  83843. * @param binaryWriter
  83844. * @param bufferViews
  83845. * @param accessors
  83846. * @param convertToRightHandedSystem
  83847. * @param animationSampleRate
  83848. */
  83849. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83850. [key: number]: number;
  83851. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83852. /**
  83853. * @ignore
  83854. * Create node and morph animations from the animation groups
  83855. * @param babylonScene
  83856. * @param glTFAnimations
  83857. * @param nodeMap
  83858. * @param nodes
  83859. * @param binaryWriter
  83860. * @param bufferViews
  83861. * @param accessors
  83862. * @param convertToRightHandedSystemMap
  83863. * @param animationSampleRate
  83864. */
  83865. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83866. [key: number]: number;
  83867. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83868. [nodeId: number]: boolean;
  83869. }, animationSampleRate: number): void;
  83870. private static AddAnimation;
  83871. /**
  83872. * Create a baked animation
  83873. * @param babylonTransformNode BabylonJS mesh
  83874. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83875. * @param animationChannelTargetPath animation target channel
  83876. * @param minFrame minimum animation frame
  83877. * @param maxFrame maximum animation frame
  83878. * @param fps frames per second of the animation
  83879. * @param inputs input key frames of the animation
  83880. * @param outputs output key frame data of the animation
  83881. * @param convertToRightHandedSystem converts the values to right-handed
  83882. * @param useQuaternion specifies if quaternions should be used
  83883. */
  83884. private static _CreateBakedAnimation;
  83885. private static _ConvertFactorToVector3OrQuaternion;
  83886. private static _SetInterpolatedValue;
  83887. /**
  83888. * Creates linear animation from the animation key frames
  83889. * @param babylonTransformNode BabylonJS mesh
  83890. * @param animation BabylonJS animation
  83891. * @param animationChannelTargetPath The target animation channel
  83892. * @param frameDelta The difference between the last and first frame of the animation
  83893. * @param inputs Array to store the key frame times
  83894. * @param outputs Array to store the key frame data
  83895. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83896. * @param useQuaternion Specifies if quaternions are used in the animation
  83897. */
  83898. private static _CreateLinearOrStepAnimation;
  83899. /**
  83900. * Creates cubic spline animation from the animation key frames
  83901. * @param babylonTransformNode BabylonJS mesh
  83902. * @param animation BabylonJS animation
  83903. * @param animationChannelTargetPath The target animation channel
  83904. * @param frameDelta The difference between the last and first frame of the animation
  83905. * @param inputs Array to store the key frame times
  83906. * @param outputs Array to store the key frame data
  83907. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83908. * @param useQuaternion Specifies if quaternions are used in the animation
  83909. */
  83910. private static _CreateCubicSplineAnimation;
  83911. private static _GetBasePositionRotationOrScale;
  83912. /**
  83913. * Adds a key frame value
  83914. * @param keyFrame
  83915. * @param animation
  83916. * @param outputs
  83917. * @param animationChannelTargetPath
  83918. * @param basePositionRotationOrScale
  83919. * @param convertToRightHandedSystem
  83920. * @param useQuaternion
  83921. */
  83922. private static _AddKeyframeValue;
  83923. /**
  83924. * Determine the interpolation based on the key frames
  83925. * @param keyFrames
  83926. * @param animationChannelTargetPath
  83927. * @param useQuaternion
  83928. */
  83929. private static _DeduceInterpolation;
  83930. /**
  83931. * Adds an input tangent or output tangent to the output data
  83932. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83933. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83934. * @param outputs The animation data by keyframe
  83935. * @param animationChannelTargetPath The target animation channel
  83936. * @param interpolation The interpolation type
  83937. * @param keyFrame The key frame with the animation data
  83938. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83939. * @param useQuaternion Specifies if quaternions are used
  83940. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83941. */
  83942. private static AddSplineTangent;
  83943. /**
  83944. * Get the minimum and maximum key frames' frame values
  83945. * @param keyFrames animation key frames
  83946. * @returns the minimum and maximum key frame value
  83947. */
  83948. private static calculateMinMaxKeyFrames;
  83949. }
  83950. }
  83951. declare module BABYLON.GLTF2.Exporter {
  83952. /** @hidden */
  83953. export var textureTransformPixelShader: {
  83954. name: string;
  83955. shader: string;
  83956. };
  83957. }
  83958. declare module BABYLON.GLTF2.Exporter.Extensions {
  83959. /**
  83960. * @hidden
  83961. */
  83962. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83963. private _recordedTextures;
  83964. /** Name of this extension */
  83965. readonly name: string;
  83966. /** Defines whether this extension is enabled */
  83967. enabled: boolean;
  83968. /** Defines whether this extension is required */
  83969. required: boolean;
  83970. /** Reference to the glTF exporter */
  83971. private _wasUsed;
  83972. constructor(exporter: _Exporter);
  83973. dispose(): void;
  83974. /** @hidden */
  83975. get wasUsed(): boolean;
  83976. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83977. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83978. /**
  83979. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83980. * @param babylonTexture
  83981. * @param offset
  83982. * @param rotation
  83983. * @param scale
  83984. * @param scene
  83985. */
  83986. private _textureTransformTextureAsync;
  83987. }
  83988. }
  83989. declare module BABYLON.GLTF2.Exporter.Extensions {
  83990. /**
  83991. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83992. */
  83993. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83994. /** The name of this extension. */
  83995. readonly name: string;
  83996. /** Defines whether this extension is enabled. */
  83997. enabled: boolean;
  83998. /** Defines whether this extension is required */
  83999. required: boolean;
  84000. /** Reference to the glTF exporter */
  84001. private _exporter;
  84002. private _lights;
  84003. /** @hidden */
  84004. constructor(exporter: _Exporter);
  84005. /** @hidden */
  84006. dispose(): void;
  84007. /** @hidden */
  84008. get wasUsed(): boolean;
  84009. /** @hidden */
  84010. onExporting(): void;
  84011. /**
  84012. * Define this method to modify the default behavior when exporting a node
  84013. * @param context The context when exporting the node
  84014. * @param node glTF node
  84015. * @param babylonNode BabylonJS node
  84016. * @param nodeMap Node mapping of unique id to glTF node index
  84017. * @returns nullable INode promise
  84018. */
  84019. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84020. [key: number]: number;
  84021. }): Promise<Nullable<INode>>;
  84022. }
  84023. }
  84024. declare module BABYLON.GLTF2.Exporter.Extensions {
  84025. /**
  84026. * @hidden
  84027. */
  84028. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84029. /** Name of this extension */
  84030. readonly name: string;
  84031. /** Defines whether this extension is enabled */
  84032. enabled: boolean;
  84033. /** Defines whether this extension is required */
  84034. required: boolean;
  84035. /** Reference to the glTF exporter */
  84036. private _textureInfos;
  84037. private _exportedTextures;
  84038. private _wasUsed;
  84039. constructor(exporter: _Exporter);
  84040. dispose(): void;
  84041. /** @hidden */
  84042. get wasUsed(): boolean;
  84043. private _getTextureIndex;
  84044. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84045. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84046. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84047. }
  84048. }
  84049. declare module BABYLON.GLTF2.Exporter.Extensions {
  84050. /**
  84051. * @hidden
  84052. */
  84053. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84054. /** Name of this extension */
  84055. readonly name: string;
  84056. /** Defines whether this extension is enabled */
  84057. enabled: boolean;
  84058. /** Defines whether this extension is required */
  84059. required: boolean;
  84060. private _wasUsed;
  84061. constructor(exporter: _Exporter);
  84062. /** @hidden */
  84063. get wasUsed(): boolean;
  84064. dispose(): void;
  84065. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84066. }
  84067. }
  84068. declare module BABYLON {
  84069. /**
  84070. * Class for generating STL data from a Babylon scene.
  84071. */
  84072. export class STLExport {
  84073. /**
  84074. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84075. * @param meshes list defines the mesh to serialize
  84076. * @param download triggers the automatic download of the file.
  84077. * @param fileName changes the downloads fileName.
  84078. * @param binary changes the STL to a binary type.
  84079. * @param isLittleEndian toggle for binary type exporter.
  84080. * @returns the STL as UTF8 string
  84081. */
  84082. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84083. }
  84084. }
  84085. declare module "babylonjs-gltf2interface" {
  84086. export = BABYLON.GLTF2;
  84087. }
  84088. /**
  84089. * Module for glTF 2.0 Interface
  84090. */
  84091. declare module BABYLON.GLTF2 {
  84092. /**
  84093. * The datatype of the components in the attribute
  84094. */
  84095. const enum AccessorComponentType {
  84096. /**
  84097. * Byte
  84098. */
  84099. BYTE = 5120,
  84100. /**
  84101. * Unsigned Byte
  84102. */
  84103. UNSIGNED_BYTE = 5121,
  84104. /**
  84105. * Short
  84106. */
  84107. SHORT = 5122,
  84108. /**
  84109. * Unsigned Short
  84110. */
  84111. UNSIGNED_SHORT = 5123,
  84112. /**
  84113. * Unsigned Int
  84114. */
  84115. UNSIGNED_INT = 5125,
  84116. /**
  84117. * Float
  84118. */
  84119. FLOAT = 5126,
  84120. }
  84121. /**
  84122. * Specifies if the attirbute is a scalar, vector, or matrix
  84123. */
  84124. const enum AccessorType {
  84125. /**
  84126. * Scalar
  84127. */
  84128. SCALAR = "SCALAR",
  84129. /**
  84130. * Vector2
  84131. */
  84132. VEC2 = "VEC2",
  84133. /**
  84134. * Vector3
  84135. */
  84136. VEC3 = "VEC3",
  84137. /**
  84138. * Vector4
  84139. */
  84140. VEC4 = "VEC4",
  84141. /**
  84142. * Matrix2x2
  84143. */
  84144. MAT2 = "MAT2",
  84145. /**
  84146. * Matrix3x3
  84147. */
  84148. MAT3 = "MAT3",
  84149. /**
  84150. * Matrix4x4
  84151. */
  84152. MAT4 = "MAT4",
  84153. }
  84154. /**
  84155. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84156. */
  84157. const enum AnimationChannelTargetPath {
  84158. /**
  84159. * Translation
  84160. */
  84161. TRANSLATION = "translation",
  84162. /**
  84163. * Rotation
  84164. */
  84165. ROTATION = "rotation",
  84166. /**
  84167. * Scale
  84168. */
  84169. SCALE = "scale",
  84170. /**
  84171. * Weights
  84172. */
  84173. WEIGHTS = "weights",
  84174. }
  84175. /**
  84176. * Interpolation algorithm
  84177. */
  84178. const enum AnimationSamplerInterpolation {
  84179. /**
  84180. * The animated values are linearly interpolated between keyframes
  84181. */
  84182. LINEAR = "LINEAR",
  84183. /**
  84184. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84185. */
  84186. STEP = "STEP",
  84187. /**
  84188. * The animation's interpolation is computed using a cubic spline with specified tangents
  84189. */
  84190. CUBICSPLINE = "CUBICSPLINE",
  84191. }
  84192. /**
  84193. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84194. */
  84195. const enum CameraType {
  84196. /**
  84197. * A perspective camera containing properties to create a perspective projection matrix
  84198. */
  84199. PERSPECTIVE = "perspective",
  84200. /**
  84201. * An orthographic camera containing properties to create an orthographic projection matrix
  84202. */
  84203. ORTHOGRAPHIC = "orthographic",
  84204. }
  84205. /**
  84206. * The mime-type of the image
  84207. */
  84208. const enum ImageMimeType {
  84209. /**
  84210. * JPEG Mime-type
  84211. */
  84212. JPEG = "image/jpeg",
  84213. /**
  84214. * PNG Mime-type
  84215. */
  84216. PNG = "image/png",
  84217. }
  84218. /**
  84219. * The alpha rendering mode of the material
  84220. */
  84221. const enum MaterialAlphaMode {
  84222. /**
  84223. * The alpha value is ignored and the rendered output is fully opaque
  84224. */
  84225. OPAQUE = "OPAQUE",
  84226. /**
  84227. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84228. */
  84229. MASK = "MASK",
  84230. /**
  84231. * 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)
  84232. */
  84233. BLEND = "BLEND",
  84234. }
  84235. /**
  84236. * The type of the primitives to render
  84237. */
  84238. const enum MeshPrimitiveMode {
  84239. /**
  84240. * Points
  84241. */
  84242. POINTS = 0,
  84243. /**
  84244. * Lines
  84245. */
  84246. LINES = 1,
  84247. /**
  84248. * Line Loop
  84249. */
  84250. LINE_LOOP = 2,
  84251. /**
  84252. * Line Strip
  84253. */
  84254. LINE_STRIP = 3,
  84255. /**
  84256. * Triangles
  84257. */
  84258. TRIANGLES = 4,
  84259. /**
  84260. * Triangle Strip
  84261. */
  84262. TRIANGLE_STRIP = 5,
  84263. /**
  84264. * Triangle Fan
  84265. */
  84266. TRIANGLE_FAN = 6,
  84267. }
  84268. /**
  84269. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84270. */
  84271. const enum TextureMagFilter {
  84272. /**
  84273. * Nearest
  84274. */
  84275. NEAREST = 9728,
  84276. /**
  84277. * Linear
  84278. */
  84279. LINEAR = 9729,
  84280. }
  84281. /**
  84282. * Minification filter. All valid values correspond to WebGL enums
  84283. */
  84284. const enum TextureMinFilter {
  84285. /**
  84286. * Nearest
  84287. */
  84288. NEAREST = 9728,
  84289. /**
  84290. * Linear
  84291. */
  84292. LINEAR = 9729,
  84293. /**
  84294. * Nearest Mip-Map Nearest
  84295. */
  84296. NEAREST_MIPMAP_NEAREST = 9984,
  84297. /**
  84298. * Linear Mipmap Nearest
  84299. */
  84300. LINEAR_MIPMAP_NEAREST = 9985,
  84301. /**
  84302. * Nearest Mipmap Linear
  84303. */
  84304. NEAREST_MIPMAP_LINEAR = 9986,
  84305. /**
  84306. * Linear Mipmap Linear
  84307. */
  84308. LINEAR_MIPMAP_LINEAR = 9987,
  84309. }
  84310. /**
  84311. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84312. */
  84313. const enum TextureWrapMode {
  84314. /**
  84315. * Clamp to Edge
  84316. */
  84317. CLAMP_TO_EDGE = 33071,
  84318. /**
  84319. * Mirrored Repeat
  84320. */
  84321. MIRRORED_REPEAT = 33648,
  84322. /**
  84323. * Repeat
  84324. */
  84325. REPEAT = 10497,
  84326. }
  84327. /**
  84328. * glTF Property
  84329. */
  84330. interface IProperty {
  84331. /**
  84332. * Dictionary object with extension-specific objects
  84333. */
  84334. extensions?: {
  84335. [key: string]: any;
  84336. };
  84337. /**
  84338. * Application-Specific data
  84339. */
  84340. extras?: any;
  84341. }
  84342. /**
  84343. * glTF Child of Root Property
  84344. */
  84345. interface IChildRootProperty extends IProperty {
  84346. /**
  84347. * The user-defined name of this object
  84348. */
  84349. name?: string;
  84350. }
  84351. /**
  84352. * Indices of those attributes that deviate from their initialization value
  84353. */
  84354. interface IAccessorSparseIndices extends IProperty {
  84355. /**
  84356. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84357. */
  84358. bufferView: number;
  84359. /**
  84360. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84361. */
  84362. byteOffset?: number;
  84363. /**
  84364. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84365. */
  84366. componentType: AccessorComponentType;
  84367. }
  84368. /**
  84369. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84370. */
  84371. interface IAccessorSparseValues extends IProperty {
  84372. /**
  84373. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84374. */
  84375. bufferView: number;
  84376. /**
  84377. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84378. */
  84379. byteOffset?: number;
  84380. }
  84381. /**
  84382. * Sparse storage of attributes that deviate from their initialization value
  84383. */
  84384. interface IAccessorSparse extends IProperty {
  84385. /**
  84386. * The number of attributes encoded in this sparse accessor
  84387. */
  84388. count: number;
  84389. /**
  84390. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84391. */
  84392. indices: IAccessorSparseIndices;
  84393. /**
  84394. * 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
  84395. */
  84396. values: IAccessorSparseValues;
  84397. }
  84398. /**
  84399. * 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
  84400. */
  84401. interface IAccessor extends IChildRootProperty {
  84402. /**
  84403. * The index of the bufferview
  84404. */
  84405. bufferView?: number;
  84406. /**
  84407. * The offset relative to the start of the bufferView in bytes
  84408. */
  84409. byteOffset?: number;
  84410. /**
  84411. * The datatype of components in the attribute
  84412. */
  84413. componentType: AccessorComponentType;
  84414. /**
  84415. * Specifies whether integer data values should be normalized
  84416. */
  84417. normalized?: boolean;
  84418. /**
  84419. * The number of attributes referenced by this accessor
  84420. */
  84421. count: number;
  84422. /**
  84423. * Specifies if the attribute is a scalar, vector, or matrix
  84424. */
  84425. type: AccessorType;
  84426. /**
  84427. * Maximum value of each component in this attribute
  84428. */
  84429. max?: number[];
  84430. /**
  84431. * Minimum value of each component in this attribute
  84432. */
  84433. min?: number[];
  84434. /**
  84435. * Sparse storage of attributes that deviate from their initialization value
  84436. */
  84437. sparse?: IAccessorSparse;
  84438. }
  84439. /**
  84440. * Targets an animation's sampler at a node's property
  84441. */
  84442. interface IAnimationChannel extends IProperty {
  84443. /**
  84444. * The index of a sampler in this animation used to compute the value for the target
  84445. */
  84446. sampler: number;
  84447. /**
  84448. * The index of the node and TRS property to target
  84449. */
  84450. target: IAnimationChannelTarget;
  84451. }
  84452. /**
  84453. * The index of the node and TRS property that an animation channel targets
  84454. */
  84455. interface IAnimationChannelTarget extends IProperty {
  84456. /**
  84457. * The index of the node to target
  84458. */
  84459. node: number;
  84460. /**
  84461. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84462. */
  84463. path: AnimationChannelTargetPath;
  84464. }
  84465. /**
  84466. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84467. */
  84468. interface IAnimationSampler extends IProperty {
  84469. /**
  84470. * The index of an accessor containing keyframe input values, e.g., time
  84471. */
  84472. input: number;
  84473. /**
  84474. * Interpolation algorithm
  84475. */
  84476. interpolation?: AnimationSamplerInterpolation;
  84477. /**
  84478. * The index of an accessor, containing keyframe output values
  84479. */
  84480. output: number;
  84481. }
  84482. /**
  84483. * A keyframe animation
  84484. */
  84485. interface IAnimation extends IChildRootProperty {
  84486. /**
  84487. * An array of channels, each of which targets an animation's sampler at a node's property
  84488. */
  84489. channels: IAnimationChannel[];
  84490. /**
  84491. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84492. */
  84493. samplers: IAnimationSampler[];
  84494. }
  84495. /**
  84496. * Metadata about the glTF asset
  84497. */
  84498. interface IAsset extends IChildRootProperty {
  84499. /**
  84500. * A copyright message suitable for display to credit the content creator
  84501. */
  84502. copyright?: string;
  84503. /**
  84504. * Tool that generated this glTF model. Useful for debugging
  84505. */
  84506. generator?: string;
  84507. /**
  84508. * The glTF version that this asset targets
  84509. */
  84510. version: string;
  84511. /**
  84512. * The minimum glTF version that this asset targets
  84513. */
  84514. minVersion?: string;
  84515. }
  84516. /**
  84517. * A buffer points to binary geometry, animation, or skins
  84518. */
  84519. interface IBuffer extends IChildRootProperty {
  84520. /**
  84521. * 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
  84522. */
  84523. uri?: string;
  84524. /**
  84525. * The length of the buffer in bytes
  84526. */
  84527. byteLength: number;
  84528. }
  84529. /**
  84530. * A view into a buffer generally representing a subset of the buffer
  84531. */
  84532. interface IBufferView extends IChildRootProperty {
  84533. /**
  84534. * The index of the buffer
  84535. */
  84536. buffer: number;
  84537. /**
  84538. * The offset into the buffer in bytes
  84539. */
  84540. byteOffset?: number;
  84541. /**
  84542. * The lenth of the bufferView in bytes
  84543. */
  84544. byteLength: number;
  84545. /**
  84546. * The stride, in bytes
  84547. */
  84548. byteStride?: number;
  84549. }
  84550. /**
  84551. * An orthographic camera containing properties to create an orthographic projection matrix
  84552. */
  84553. interface ICameraOrthographic extends IProperty {
  84554. /**
  84555. * The floating-point horizontal magnification of the view. Must not be zero
  84556. */
  84557. xmag: number;
  84558. /**
  84559. * The floating-point vertical magnification of the view. Must not be zero
  84560. */
  84561. ymag: number;
  84562. /**
  84563. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84564. */
  84565. zfar: number;
  84566. /**
  84567. * The floating-point distance to the near clipping plane
  84568. */
  84569. znear: number;
  84570. }
  84571. /**
  84572. * A perspective camera containing properties to create a perspective projection matrix
  84573. */
  84574. interface ICameraPerspective extends IProperty {
  84575. /**
  84576. * The floating-point aspect ratio of the field of view
  84577. */
  84578. aspectRatio?: number;
  84579. /**
  84580. * The floating-point vertical field of view in radians
  84581. */
  84582. yfov: number;
  84583. /**
  84584. * The floating-point distance to the far clipping plane
  84585. */
  84586. zfar?: number;
  84587. /**
  84588. * The floating-point distance to the near clipping plane
  84589. */
  84590. znear: number;
  84591. }
  84592. /**
  84593. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84594. */
  84595. interface ICamera extends IChildRootProperty {
  84596. /**
  84597. * An orthographic camera containing properties to create an orthographic projection matrix
  84598. */
  84599. orthographic?: ICameraOrthographic;
  84600. /**
  84601. * A perspective camera containing properties to create a perspective projection matrix
  84602. */
  84603. perspective?: ICameraPerspective;
  84604. /**
  84605. * Specifies if the camera uses a perspective or orthographic projection
  84606. */
  84607. type: CameraType;
  84608. }
  84609. /**
  84610. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84611. */
  84612. interface IImage extends IChildRootProperty {
  84613. /**
  84614. * 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
  84615. */
  84616. uri?: string;
  84617. /**
  84618. * The image's MIME type
  84619. */
  84620. mimeType?: ImageMimeType;
  84621. /**
  84622. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84623. */
  84624. bufferView?: number;
  84625. }
  84626. /**
  84627. * Material Normal Texture Info
  84628. */
  84629. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84630. /**
  84631. * The scalar multiplier applied to each normal vector of the normal texture
  84632. */
  84633. scale?: number;
  84634. }
  84635. /**
  84636. * Material Occlusion Texture Info
  84637. */
  84638. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84639. /**
  84640. * A scalar multiplier controlling the amount of occlusion applied
  84641. */
  84642. strength?: number;
  84643. }
  84644. /**
  84645. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84646. */
  84647. interface IMaterialPbrMetallicRoughness {
  84648. /**
  84649. * The material's base color factor
  84650. */
  84651. baseColorFactor?: number[];
  84652. /**
  84653. * The base color texture
  84654. */
  84655. baseColorTexture?: ITextureInfo;
  84656. /**
  84657. * The metalness of the material
  84658. */
  84659. metallicFactor?: number;
  84660. /**
  84661. * The roughness of the material
  84662. */
  84663. roughnessFactor?: number;
  84664. /**
  84665. * The metallic-roughness texture
  84666. */
  84667. metallicRoughnessTexture?: ITextureInfo;
  84668. }
  84669. /**
  84670. * The material appearance of a primitive
  84671. */
  84672. interface IMaterial extends IChildRootProperty {
  84673. /**
  84674. * 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
  84675. */
  84676. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84677. /**
  84678. * The normal map texture
  84679. */
  84680. normalTexture?: IMaterialNormalTextureInfo;
  84681. /**
  84682. * The occlusion map texture
  84683. */
  84684. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84685. /**
  84686. * The emissive map texture
  84687. */
  84688. emissiveTexture?: ITextureInfo;
  84689. /**
  84690. * 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
  84691. */
  84692. emissiveFactor?: number[];
  84693. /**
  84694. * The alpha rendering mode of the material
  84695. */
  84696. alphaMode?: MaterialAlphaMode;
  84697. /**
  84698. * The alpha cutoff value of the material
  84699. */
  84700. alphaCutoff?: number;
  84701. /**
  84702. * Specifies whether the material is double sided
  84703. */
  84704. doubleSided?: boolean;
  84705. }
  84706. /**
  84707. * Geometry to be rendered with the given material
  84708. */
  84709. interface IMeshPrimitive extends IProperty {
  84710. /**
  84711. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84712. */
  84713. attributes: {
  84714. [name: string]: number;
  84715. };
  84716. /**
  84717. * The index of the accessor that contains the indices
  84718. */
  84719. indices?: number;
  84720. /**
  84721. * The index of the material to apply to this primitive when rendering
  84722. */
  84723. material?: number;
  84724. /**
  84725. * The type of primitives to render. All valid values correspond to WebGL enums
  84726. */
  84727. mode?: MeshPrimitiveMode;
  84728. /**
  84729. * 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
  84730. */
  84731. targets?: {
  84732. [name: string]: number;
  84733. }[];
  84734. }
  84735. /**
  84736. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84737. */
  84738. interface IMesh extends IChildRootProperty {
  84739. /**
  84740. * An array of primitives, each defining geometry to be rendered with a material
  84741. */
  84742. primitives: IMeshPrimitive[];
  84743. /**
  84744. * Array of weights to be applied to the Morph Targets
  84745. */
  84746. weights?: number[];
  84747. }
  84748. /**
  84749. * A node in the node hierarchy
  84750. */
  84751. interface INode extends IChildRootProperty {
  84752. /**
  84753. * The index of the camera referenced by this node
  84754. */
  84755. camera?: number;
  84756. /**
  84757. * The indices of this node's children
  84758. */
  84759. children?: number[];
  84760. /**
  84761. * The index of the skin referenced by this node
  84762. */
  84763. skin?: number;
  84764. /**
  84765. * A floating-point 4x4 transformation matrix stored in column-major order
  84766. */
  84767. matrix?: number[];
  84768. /**
  84769. * The index of the mesh in this node
  84770. */
  84771. mesh?: number;
  84772. /**
  84773. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84774. */
  84775. rotation?: number[];
  84776. /**
  84777. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84778. */
  84779. scale?: number[];
  84780. /**
  84781. * The node's translation along the x, y, and z axes
  84782. */
  84783. translation?: number[];
  84784. /**
  84785. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84786. */
  84787. weights?: number[];
  84788. }
  84789. /**
  84790. * Texture sampler properties for filtering and wrapping modes
  84791. */
  84792. interface ISampler extends IChildRootProperty {
  84793. /**
  84794. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84795. */
  84796. magFilter?: TextureMagFilter;
  84797. /**
  84798. * Minification filter. All valid values correspond to WebGL enums
  84799. */
  84800. minFilter?: TextureMinFilter;
  84801. /**
  84802. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84803. */
  84804. wrapS?: TextureWrapMode;
  84805. /**
  84806. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84807. */
  84808. wrapT?: TextureWrapMode;
  84809. }
  84810. /**
  84811. * The root nodes of a scene
  84812. */
  84813. interface IScene extends IChildRootProperty {
  84814. /**
  84815. * The indices of each root node
  84816. */
  84817. nodes: number[];
  84818. }
  84819. /**
  84820. * Joints and matrices defining a skin
  84821. */
  84822. interface ISkin extends IChildRootProperty {
  84823. /**
  84824. * 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
  84825. */
  84826. inverseBindMatrices?: number;
  84827. /**
  84828. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84829. */
  84830. skeleton?: number;
  84831. /**
  84832. * 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)
  84833. */
  84834. joints: number[];
  84835. }
  84836. /**
  84837. * A texture and its sampler
  84838. */
  84839. interface ITexture extends IChildRootProperty {
  84840. /**
  84841. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84842. */
  84843. sampler?: number;
  84844. /**
  84845. * The index of the image used by this texture
  84846. */
  84847. source: number;
  84848. }
  84849. /**
  84850. * Reference to a texture
  84851. */
  84852. interface ITextureInfo extends IProperty {
  84853. /**
  84854. * The index of the texture
  84855. */
  84856. index: number;
  84857. /**
  84858. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84859. */
  84860. texCoord?: number;
  84861. }
  84862. /**
  84863. * The root object for a glTF asset
  84864. */
  84865. interface IGLTF extends IProperty {
  84866. /**
  84867. * An array of accessors. An accessor is a typed view into a bufferView
  84868. */
  84869. accessors?: IAccessor[];
  84870. /**
  84871. * An array of keyframe animations
  84872. */
  84873. animations?: IAnimation[];
  84874. /**
  84875. * Metadata about the glTF asset
  84876. */
  84877. asset: IAsset;
  84878. /**
  84879. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84880. */
  84881. buffers?: IBuffer[];
  84882. /**
  84883. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84884. */
  84885. bufferViews?: IBufferView[];
  84886. /**
  84887. * An array of cameras
  84888. */
  84889. cameras?: ICamera[];
  84890. /**
  84891. * Names of glTF extensions used somewhere in this asset
  84892. */
  84893. extensionsUsed?: string[];
  84894. /**
  84895. * Names of glTF extensions required to properly load this asset
  84896. */
  84897. extensionsRequired?: string[];
  84898. /**
  84899. * An array of images. An image defines data used to create a texture
  84900. */
  84901. images?: IImage[];
  84902. /**
  84903. * An array of materials. A material defines the appearance of a primitive
  84904. */
  84905. materials?: IMaterial[];
  84906. /**
  84907. * An array of meshes. A mesh is a set of primitives to be rendered
  84908. */
  84909. meshes?: IMesh[];
  84910. /**
  84911. * An array of nodes
  84912. */
  84913. nodes?: INode[];
  84914. /**
  84915. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84916. */
  84917. samplers?: ISampler[];
  84918. /**
  84919. * The index of the default scene
  84920. */
  84921. scene?: number;
  84922. /**
  84923. * An array of scenes
  84924. */
  84925. scenes?: IScene[];
  84926. /**
  84927. * An array of skins. A skin is defined by joints and matrices
  84928. */
  84929. skins?: ISkin[];
  84930. /**
  84931. * An array of textures
  84932. */
  84933. textures?: ITexture[];
  84934. }
  84935. /**
  84936. * The glTF validation results
  84937. * @ignore
  84938. */
  84939. interface IGLTFValidationResults {
  84940. info: {
  84941. generator: string;
  84942. hasAnimations: boolean;
  84943. hasDefaultScene: boolean;
  84944. hasMaterials: boolean;
  84945. hasMorphTargets: boolean;
  84946. hasSkins: boolean;
  84947. hasTextures: boolean;
  84948. maxAttributesUsed: number;
  84949. primitivesCount: number
  84950. };
  84951. issues: {
  84952. messages: Array<string>;
  84953. numErrors: number;
  84954. numHints: number;
  84955. numInfos: number;
  84956. numWarnings: number;
  84957. truncated: boolean
  84958. };
  84959. mimeType: string;
  84960. uri: string;
  84961. validatedAt: string;
  84962. validatorVersion: string;
  84963. }
  84964. /**
  84965. * The glTF validation options
  84966. */
  84967. interface IGLTFValidationOptions {
  84968. /** Uri to use */
  84969. uri?: string;
  84970. /** Function used to load external resources */
  84971. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84972. /** Boolean indicating that we need to validate accessor data */
  84973. validateAccessorData?: boolean;
  84974. /** max number of issues allowed */
  84975. maxIssues?: number;
  84976. /** Ignored issues */
  84977. ignoredIssues?: Array<string>;
  84978. /** Value to override severy settings */
  84979. severityOverrides?: Object;
  84980. }
  84981. /**
  84982. * The glTF validator object
  84983. * @ignore
  84984. */
  84985. interface IGLTFValidator {
  84986. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84987. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84988. }
  84989. /**
  84990. * Interfaces from the EXT_lights_image_based extension
  84991. */
  84992. /** @hidden */
  84993. interface IEXTLightsImageBased_LightReferenceImageBased {
  84994. light: number;
  84995. }
  84996. /** @hidden */
  84997. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84998. intensity: number;
  84999. rotation: number[];
  85000. specularImageSize: number;
  85001. specularImages: number[][];
  85002. irradianceCoefficients: number[][];
  85003. }
  85004. /** @hidden */
  85005. interface IEXTLightsImageBased {
  85006. lights: IEXTLightsImageBased_LightImageBased[];
  85007. }
  85008. /**
  85009. * Interfaces from the EXT_mesh_gpu_instancing extension
  85010. * !!! Experimental Extension Subject to Changes !!!
  85011. */
  85012. /** @hidden */
  85013. interface IEXTMeshGpuInstancing {
  85014. mesh?: number;
  85015. attributes: { [name: string]: number };
  85016. }
  85017. /**
  85018. * Interfaces from the KHR_draco_mesh_compression extension
  85019. */
  85020. /** @hidden */
  85021. interface IKHRDracoMeshCompression {
  85022. bufferView: number;
  85023. attributes: { [name: string]: number };
  85024. }
  85025. /**
  85026. * Interfaces from the KHR_lights_punctual extension
  85027. */
  85028. /** @hidden */
  85029. const enum IKHRLightsPunctual_LightType {
  85030. DIRECTIONAL = "directional",
  85031. POINT = "point",
  85032. SPOT = "spot"
  85033. }
  85034. /** @hidden */
  85035. interface IKHRLightsPunctual_LightReference {
  85036. light: number;
  85037. }
  85038. /** @hidden */
  85039. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85040. type: IKHRLightsPunctual_LightType;
  85041. color?: number[];
  85042. intensity?: number;
  85043. range?: number;
  85044. spot?: {
  85045. innerConeAngle?: number;
  85046. outerConeAngle?: number;
  85047. };
  85048. }
  85049. /** @hidden */
  85050. interface IKHRLightsPunctual {
  85051. lights: IKHRLightsPunctual_Light[];
  85052. }
  85053. /**
  85054. * Interfaces from the KHR_materials_clearcoat extension
  85055. * !!! Experimental Extension Subject to Changes !!!
  85056. */
  85057. /** @hidden */
  85058. interface IKHRMaterialsClearcoat {
  85059. clearcoatFactor: number;
  85060. clearcoatTexture: ITextureInfo;
  85061. clearcoatRoughnessFactor: number;
  85062. clearcoatRoughnessTexture: ITextureInfo;
  85063. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85064. }
  85065. /**
  85066. * Interfaces from the KHR_materials_ior extension
  85067. * !!! Experimental Extension Subject to Changes !!!
  85068. */
  85069. /** @hidden */
  85070. interface IKHRMaterialsIor {
  85071. ior: number;
  85072. }
  85073. /**
  85074. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85075. */
  85076. /** @hidden */
  85077. interface IKHRMaterialsPbrSpecularGlossiness {
  85078. diffuseFactor: number[];
  85079. diffuseTexture: ITextureInfo;
  85080. specularFactor: number[];
  85081. glossinessFactor: number;
  85082. specularGlossinessTexture: ITextureInfo;
  85083. }
  85084. /**
  85085. * Interfaces from the KHR_materials_sheen extension
  85086. * !!! Experimental Extension Subject to Changes !!!
  85087. */
  85088. /** @hidden */
  85089. interface IKHRMaterialsSheen {
  85090. sheenColorFactor?: number[];
  85091. sheenTexture?: ITextureInfo;
  85092. sheenRoughnessFactor?: number;
  85093. }
  85094. /**
  85095. * Interfaces from the KHR_materials_specular extension
  85096. * !!! Experimental Extension Subject to Changes !!!
  85097. */
  85098. /** @hidden */
  85099. interface IKHRMaterialsSpecular {
  85100. specularFactor: number;
  85101. specularColorFactor: number[];
  85102. specularTexture: ITextureInfo;
  85103. }
  85104. /**
  85105. * Interfaces from the KHR_materials_transmission extension
  85106. * !!! Experimental Extension Subject to Changes !!!
  85107. */
  85108. /** @hidden */
  85109. interface IKHRMaterialsTransmission {
  85110. transmissionFactor?: number;
  85111. transmissionTexture?: ITextureInfo;
  85112. }
  85113. /**
  85114. * Interfaces from the KHR_materials_variants extension
  85115. * !!! Experimental Extension Subject to Changes !!!
  85116. */
  85117. /** @hidden */
  85118. interface IKHRMaterialVariants_Mapping extends IProperty {
  85119. mappings: Array<{
  85120. variants: number[];
  85121. material: number;
  85122. }>;
  85123. }
  85124. /** @hidden */
  85125. interface IKHRMaterialVariants_Variant extends IProperty {
  85126. name: string;
  85127. }
  85128. /** @hidden */
  85129. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85130. variants: Array<IKHRMaterialVariants_Variant>;
  85131. }
  85132. /**
  85133. * Interfaces from the KHR_texture_basisu extension
  85134. * !!! Experimental Extension Subject to Changes !!!
  85135. */
  85136. /** @hidden */
  85137. interface IKHRTextureBasisU {
  85138. source: number;
  85139. }
  85140. /**
  85141. * Interfaces from the EXT_texture_webp extension
  85142. */
  85143. /** @hidden */
  85144. interface IEXTTextureWebP {
  85145. source: number;
  85146. }
  85147. /**
  85148. * Interfaces from the KHR_texture_transform extension
  85149. */
  85150. /** @hidden */
  85151. interface IKHRTextureTransform {
  85152. offset?: number[];
  85153. rotation?: number;
  85154. scale?: number[];
  85155. texCoord?: number;
  85156. }
  85157. /**
  85158. * Interfaces from the KHR_xmp extension
  85159. * !!! Experimental Extension Subject to Changes !!!
  85160. */
  85161. /** @hidden */
  85162. interface IKHRXmp_Data {
  85163. [key: string]: unknown;
  85164. }
  85165. /** @hidden */
  85166. interface IKHRXmp_Gltf {
  85167. packets: IKHRXmp_Data[];
  85168. }
  85169. /** @hidden */
  85170. interface IKHRXmp_Node {
  85171. packet: number;
  85172. }
  85173. /**
  85174. * Interfaces from the MSFT_audio_emitter extension
  85175. */
  85176. /** @hidden */
  85177. interface IMSFTAudioEmitter_ClipReference {
  85178. clip: number;
  85179. weight?: number;
  85180. }
  85181. /** @hidden */
  85182. interface IMSFTAudioEmitter_EmittersReference {
  85183. emitters: number[];
  85184. }
  85185. /** @hidden */
  85186. const enum IMSFTAudioEmitter_DistanceModel {
  85187. linear = "linear",
  85188. inverse = "inverse",
  85189. exponential = "exponential",
  85190. }
  85191. /** @hidden */
  85192. interface IMSFTAudioEmitter_Emitter {
  85193. name?: string;
  85194. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85195. refDistance?: number;
  85196. maxDistance?: number;
  85197. rolloffFactor?: number;
  85198. innerAngle?: number;
  85199. outerAngle?: number;
  85200. loop?: boolean;
  85201. volume?: number;
  85202. clips: IMSFTAudioEmitter_ClipReference[];
  85203. }
  85204. /** @hidden */
  85205. const enum IMSFTAudioEmitter_AudioMimeType {
  85206. WAV = "audio/wav",
  85207. }
  85208. /** @hidden */
  85209. interface IMSFTAudioEmitter_Clip extends IProperty {
  85210. uri?: string;
  85211. bufferView?: number;
  85212. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85213. }
  85214. /** @hidden */
  85215. const enum IMSFTAudioEmitter_AnimationEventAction {
  85216. play = "play",
  85217. pause = "pause",
  85218. stop = "stop",
  85219. }
  85220. /** @hidden */
  85221. interface IMSFTAudioEmitter_AnimationEvent {
  85222. action: IMSFTAudioEmitter_AnimationEventAction;
  85223. emitter: number;
  85224. time: number;
  85225. startOffset?: number;
  85226. }
  85227. /**
  85228. * Interfaces from the MSFT_lod extension
  85229. */
  85230. /** @hidden */
  85231. interface IMSFTLOD {
  85232. ids: number[];
  85233. }
  85234. }
  85235. declare module BABYLON {
  85236. /** @hidden */
  85237. export var cellPixelShader: {
  85238. name: string;
  85239. shader: string;
  85240. };
  85241. }
  85242. declare module BABYLON {
  85243. /** @hidden */
  85244. export var cellVertexShader: {
  85245. name: string;
  85246. shader: string;
  85247. };
  85248. }
  85249. declare module BABYLON {
  85250. export class CellMaterial extends BABYLON.PushMaterial {
  85251. private _diffuseTexture;
  85252. diffuseTexture: BABYLON.BaseTexture;
  85253. diffuseColor: BABYLON.Color3;
  85254. _computeHighLevel: boolean;
  85255. computeHighLevel: boolean;
  85256. private _disableLighting;
  85257. disableLighting: boolean;
  85258. private _maxSimultaneousLights;
  85259. maxSimultaneousLights: number;
  85260. constructor(name: string, scene: BABYLON.Scene);
  85261. needAlphaBlending(): boolean;
  85262. needAlphaTesting(): boolean;
  85263. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85264. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85265. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85266. getAnimatables(): BABYLON.IAnimatable[];
  85267. getActiveTextures(): BABYLON.BaseTexture[];
  85268. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85269. dispose(forceDisposeEffect?: boolean): void;
  85270. getClassName(): string;
  85271. clone(name: string): CellMaterial;
  85272. serialize(): any;
  85273. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85274. }
  85275. }
  85276. declare module BABYLON {
  85277. export class CustomShaderStructure {
  85278. FragmentStore: string;
  85279. VertexStore: string;
  85280. constructor();
  85281. }
  85282. export class ShaderSpecialParts {
  85283. constructor();
  85284. Fragment_Begin: string;
  85285. Fragment_Definitions: string;
  85286. Fragment_MainBegin: string;
  85287. Fragment_Custom_Diffuse: string;
  85288. Fragment_Before_Lights: string;
  85289. Fragment_Before_Fog: string;
  85290. Fragment_Custom_Alpha: string;
  85291. Fragment_Before_FragColor: string;
  85292. Vertex_Begin: string;
  85293. Vertex_Definitions: string;
  85294. Vertex_MainBegin: string;
  85295. Vertex_Before_PositionUpdated: string;
  85296. Vertex_Before_NormalUpdated: string;
  85297. Vertex_After_WorldPosComputed: string;
  85298. Vertex_MainEnd: string;
  85299. }
  85300. export class CustomMaterial extends BABYLON.StandardMaterial {
  85301. static ShaderIndexer: number;
  85302. CustomParts: ShaderSpecialParts;
  85303. _isCreatedShader: boolean;
  85304. _createdShaderName: string;
  85305. _customUniform: string[];
  85306. _newUniforms: string[];
  85307. _newUniformInstances: {
  85308. [name: string]: any;
  85309. };
  85310. _newSamplerInstances: {
  85311. [name: string]: BABYLON.Texture;
  85312. };
  85313. _customAttributes: string[];
  85314. FragmentShader: string;
  85315. VertexShader: string;
  85316. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85317. ReviewUniform(name: string, arr: string[]): string[];
  85318. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85319. constructor(name: string, scene: BABYLON.Scene);
  85320. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85321. AddAttribute(name: string): CustomMaterial;
  85322. Fragment_Begin(shaderPart: string): CustomMaterial;
  85323. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85324. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85325. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85326. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85327. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85328. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85329. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85330. Vertex_Begin(shaderPart: string): CustomMaterial;
  85331. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85332. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85333. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85334. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85335. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85336. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85337. }
  85338. }
  85339. declare module BABYLON {
  85340. export class ShaderAlebdoParts {
  85341. constructor();
  85342. Fragment_Begin: string;
  85343. Fragment_Definitions: string;
  85344. Fragment_MainBegin: string;
  85345. Fragment_Custom_Albedo: string;
  85346. Fragment_Before_Lights: string;
  85347. Fragment_Custom_MetallicRoughness: string;
  85348. Fragment_Custom_MicroSurface: string;
  85349. Fragment_Before_Fog: string;
  85350. Fragment_Custom_Alpha: string;
  85351. Fragment_Before_FragColor: string;
  85352. Vertex_Begin: string;
  85353. Vertex_Definitions: string;
  85354. Vertex_MainBegin: string;
  85355. Vertex_Before_PositionUpdated: string;
  85356. Vertex_Before_NormalUpdated: string;
  85357. Vertex_After_WorldPosComputed: string;
  85358. Vertex_MainEnd: string;
  85359. }
  85360. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85361. static ShaderIndexer: number;
  85362. CustomParts: ShaderAlebdoParts;
  85363. _isCreatedShader: boolean;
  85364. _createdShaderName: string;
  85365. _customUniform: string[];
  85366. _newUniforms: string[];
  85367. _newUniformInstances: {
  85368. [name: string]: any;
  85369. };
  85370. _newSamplerInstances: {
  85371. [name: string]: BABYLON.Texture;
  85372. };
  85373. _customAttributes: string[];
  85374. FragmentShader: string;
  85375. VertexShader: string;
  85376. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85377. ReviewUniform(name: string, arr: string[]): string[];
  85378. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85379. constructor(name: string, scene: BABYLON.Scene);
  85380. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85381. AddAttribute(name: string): PBRCustomMaterial;
  85382. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85383. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85384. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85385. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85386. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85387. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85388. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85389. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85390. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85391. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85392. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85393. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85394. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85395. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85396. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85397. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85398. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85399. }
  85400. }
  85401. declare module BABYLON {
  85402. /** @hidden */
  85403. export var firePixelShader: {
  85404. name: string;
  85405. shader: string;
  85406. };
  85407. }
  85408. declare module BABYLON {
  85409. /** @hidden */
  85410. export var fireVertexShader: {
  85411. name: string;
  85412. shader: string;
  85413. };
  85414. }
  85415. declare module BABYLON {
  85416. export class FireMaterial extends BABYLON.PushMaterial {
  85417. private _diffuseTexture;
  85418. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85419. private _distortionTexture;
  85420. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85421. private _opacityTexture;
  85422. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85423. diffuseColor: BABYLON.Color3;
  85424. speed: number;
  85425. private _scaledDiffuse;
  85426. private _lastTime;
  85427. constructor(name: string, scene: BABYLON.Scene);
  85428. needAlphaBlending(): boolean;
  85429. needAlphaTesting(): boolean;
  85430. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85431. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85432. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85433. getAnimatables(): BABYLON.IAnimatable[];
  85434. getActiveTextures(): BABYLON.BaseTexture[];
  85435. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85436. getClassName(): string;
  85437. dispose(forceDisposeEffect?: boolean): void;
  85438. clone(name: string): FireMaterial;
  85439. serialize(): any;
  85440. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85441. }
  85442. }
  85443. declare module BABYLON {
  85444. /** @hidden */
  85445. export var furPixelShader: {
  85446. name: string;
  85447. shader: string;
  85448. };
  85449. }
  85450. declare module BABYLON {
  85451. /** @hidden */
  85452. export var furVertexShader: {
  85453. name: string;
  85454. shader: string;
  85455. };
  85456. }
  85457. declare module BABYLON {
  85458. export class FurMaterial extends BABYLON.PushMaterial {
  85459. private _diffuseTexture;
  85460. diffuseTexture: BABYLON.BaseTexture;
  85461. private _heightTexture;
  85462. heightTexture: BABYLON.BaseTexture;
  85463. diffuseColor: BABYLON.Color3;
  85464. furLength: number;
  85465. furAngle: number;
  85466. furColor: BABYLON.Color3;
  85467. furOffset: number;
  85468. furSpacing: number;
  85469. furGravity: BABYLON.Vector3;
  85470. furSpeed: number;
  85471. furDensity: number;
  85472. furOcclusion: number;
  85473. furTexture: BABYLON.DynamicTexture;
  85474. private _disableLighting;
  85475. disableLighting: boolean;
  85476. private _maxSimultaneousLights;
  85477. maxSimultaneousLights: number;
  85478. highLevelFur: boolean;
  85479. _meshes: BABYLON.AbstractMesh[];
  85480. private _furTime;
  85481. constructor(name: string, scene: BABYLON.Scene);
  85482. get furTime(): number;
  85483. set furTime(furTime: number);
  85484. needAlphaBlending(): boolean;
  85485. needAlphaTesting(): boolean;
  85486. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85487. updateFur(): void;
  85488. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85489. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85490. getAnimatables(): BABYLON.IAnimatable[];
  85491. getActiveTextures(): BABYLON.BaseTexture[];
  85492. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85493. dispose(forceDisposeEffect?: boolean): void;
  85494. clone(name: string): FurMaterial;
  85495. serialize(): any;
  85496. getClassName(): string;
  85497. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85498. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85499. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85500. }
  85501. }
  85502. declare module BABYLON {
  85503. /** @hidden */
  85504. export var gradientPixelShader: {
  85505. name: string;
  85506. shader: string;
  85507. };
  85508. }
  85509. declare module BABYLON {
  85510. /** @hidden */
  85511. export var gradientVertexShader: {
  85512. name: string;
  85513. shader: string;
  85514. };
  85515. }
  85516. declare module BABYLON {
  85517. export class GradientMaterial extends BABYLON.PushMaterial {
  85518. private _maxSimultaneousLights;
  85519. maxSimultaneousLights: number;
  85520. topColor: BABYLON.Color3;
  85521. topColorAlpha: number;
  85522. bottomColor: BABYLON.Color3;
  85523. bottomColorAlpha: number;
  85524. offset: number;
  85525. scale: number;
  85526. smoothness: number;
  85527. private _disableLighting;
  85528. disableLighting: boolean;
  85529. constructor(name: string, scene: BABYLON.Scene);
  85530. needAlphaBlending(): boolean;
  85531. needAlphaTesting(): boolean;
  85532. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85533. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85534. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85535. getAnimatables(): BABYLON.IAnimatable[];
  85536. dispose(forceDisposeEffect?: boolean): void;
  85537. clone(name: string): GradientMaterial;
  85538. serialize(): any;
  85539. getClassName(): string;
  85540. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85541. }
  85542. }
  85543. declare module BABYLON {
  85544. /** @hidden */
  85545. export var gridPixelShader: {
  85546. name: string;
  85547. shader: string;
  85548. };
  85549. }
  85550. declare module BABYLON {
  85551. /** @hidden */
  85552. export var gridVertexShader: {
  85553. name: string;
  85554. shader: string;
  85555. };
  85556. }
  85557. declare module BABYLON {
  85558. /**
  85559. * The grid materials allows you to wrap any shape with a grid.
  85560. * Colors are customizable.
  85561. */
  85562. export class GridMaterial extends BABYLON.PushMaterial {
  85563. /**
  85564. * Main color of the grid (e.g. between lines)
  85565. */
  85566. mainColor: BABYLON.Color3;
  85567. /**
  85568. * Color of the grid lines.
  85569. */
  85570. lineColor: BABYLON.Color3;
  85571. /**
  85572. * The scale of the grid compared to unit.
  85573. */
  85574. gridRatio: number;
  85575. /**
  85576. * Allows setting an offset for the grid lines.
  85577. */
  85578. gridOffset: BABYLON.Vector3;
  85579. /**
  85580. * The frequency of thicker lines.
  85581. */
  85582. majorUnitFrequency: number;
  85583. /**
  85584. * The visibility of minor units in the grid.
  85585. */
  85586. minorUnitVisibility: number;
  85587. /**
  85588. * The grid opacity outside of the lines.
  85589. */
  85590. opacity: number;
  85591. /**
  85592. * Determine RBG output is premultiplied by alpha value.
  85593. */
  85594. preMultiplyAlpha: boolean;
  85595. private _opacityTexture;
  85596. opacityTexture: BABYLON.BaseTexture;
  85597. private _gridControl;
  85598. /**
  85599. * constructor
  85600. * @param name The name given to the material in order to identify it afterwards.
  85601. * @param scene The scene the material is used in.
  85602. */
  85603. constructor(name: string, scene: BABYLON.Scene);
  85604. /**
  85605. * Returns wehter or not the grid requires alpha blending.
  85606. */
  85607. needAlphaBlending(): boolean;
  85608. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85609. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85610. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85611. /**
  85612. * Dispose the material and its associated resources.
  85613. * @param forceDisposeEffect will also dispose the used effect when true
  85614. */
  85615. dispose(forceDisposeEffect?: boolean): void;
  85616. clone(name: string): GridMaterial;
  85617. serialize(): any;
  85618. getClassName(): string;
  85619. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85620. }
  85621. }
  85622. declare module BABYLON {
  85623. /** @hidden */
  85624. export var lavaPixelShader: {
  85625. name: string;
  85626. shader: string;
  85627. };
  85628. }
  85629. declare module BABYLON {
  85630. /** @hidden */
  85631. export var lavaVertexShader: {
  85632. name: string;
  85633. shader: string;
  85634. };
  85635. }
  85636. declare module BABYLON {
  85637. export class LavaMaterial extends BABYLON.PushMaterial {
  85638. private _diffuseTexture;
  85639. diffuseTexture: BABYLON.BaseTexture;
  85640. noiseTexture: BABYLON.BaseTexture;
  85641. fogColor: BABYLON.Color3;
  85642. speed: number;
  85643. movingSpeed: number;
  85644. lowFrequencySpeed: number;
  85645. fogDensity: number;
  85646. private _lastTime;
  85647. diffuseColor: BABYLON.Color3;
  85648. private _disableLighting;
  85649. disableLighting: boolean;
  85650. private _unlit;
  85651. unlit: boolean;
  85652. private _maxSimultaneousLights;
  85653. maxSimultaneousLights: number;
  85654. private _scaledDiffuse;
  85655. constructor(name: string, scene: BABYLON.Scene);
  85656. needAlphaBlending(): boolean;
  85657. needAlphaTesting(): boolean;
  85658. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85659. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85660. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85661. getAnimatables(): BABYLON.IAnimatable[];
  85662. getActiveTextures(): BABYLON.BaseTexture[];
  85663. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85664. dispose(forceDisposeEffect?: boolean): void;
  85665. clone(name: string): LavaMaterial;
  85666. serialize(): any;
  85667. getClassName(): string;
  85668. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85669. }
  85670. }
  85671. declare module BABYLON {
  85672. /** @hidden */
  85673. export var mixPixelShader: {
  85674. name: string;
  85675. shader: string;
  85676. };
  85677. }
  85678. declare module BABYLON {
  85679. /** @hidden */
  85680. export var mixVertexShader: {
  85681. name: string;
  85682. shader: string;
  85683. };
  85684. }
  85685. declare module BABYLON {
  85686. export class MixMaterial extends BABYLON.PushMaterial {
  85687. /**
  85688. * Mix textures
  85689. */
  85690. private _mixTexture1;
  85691. mixTexture1: BABYLON.BaseTexture;
  85692. private _mixTexture2;
  85693. mixTexture2: BABYLON.BaseTexture;
  85694. /**
  85695. * Diffuse textures
  85696. */
  85697. private _diffuseTexture1;
  85698. diffuseTexture1: BABYLON.Texture;
  85699. private _diffuseTexture2;
  85700. diffuseTexture2: BABYLON.Texture;
  85701. private _diffuseTexture3;
  85702. diffuseTexture3: BABYLON.Texture;
  85703. private _diffuseTexture4;
  85704. diffuseTexture4: BABYLON.Texture;
  85705. private _diffuseTexture5;
  85706. diffuseTexture5: BABYLON.Texture;
  85707. private _diffuseTexture6;
  85708. diffuseTexture6: BABYLON.Texture;
  85709. private _diffuseTexture7;
  85710. diffuseTexture7: BABYLON.Texture;
  85711. private _diffuseTexture8;
  85712. diffuseTexture8: BABYLON.Texture;
  85713. /**
  85714. * Uniforms
  85715. */
  85716. diffuseColor: BABYLON.Color3;
  85717. specularColor: BABYLON.Color3;
  85718. specularPower: number;
  85719. private _disableLighting;
  85720. disableLighting: boolean;
  85721. private _maxSimultaneousLights;
  85722. maxSimultaneousLights: number;
  85723. constructor(name: string, scene: BABYLON.Scene);
  85724. needAlphaBlending(): boolean;
  85725. needAlphaTesting(): boolean;
  85726. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85727. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85728. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85729. getAnimatables(): BABYLON.IAnimatable[];
  85730. getActiveTextures(): BABYLON.BaseTexture[];
  85731. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85732. dispose(forceDisposeEffect?: boolean): void;
  85733. clone(name: string): MixMaterial;
  85734. serialize(): any;
  85735. getClassName(): string;
  85736. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85737. }
  85738. }
  85739. declare module BABYLON {
  85740. /** @hidden */
  85741. export var normalPixelShader: {
  85742. name: string;
  85743. shader: string;
  85744. };
  85745. }
  85746. declare module BABYLON {
  85747. /** @hidden */
  85748. export var normalVertexShader: {
  85749. name: string;
  85750. shader: string;
  85751. };
  85752. }
  85753. declare module BABYLON {
  85754. export class NormalMaterial extends BABYLON.PushMaterial {
  85755. private _diffuseTexture;
  85756. diffuseTexture: BABYLON.BaseTexture;
  85757. diffuseColor: BABYLON.Color3;
  85758. private _disableLighting;
  85759. disableLighting: boolean;
  85760. private _maxSimultaneousLights;
  85761. maxSimultaneousLights: number;
  85762. constructor(name: string, scene: BABYLON.Scene);
  85763. needAlphaBlending(): boolean;
  85764. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85765. needAlphaTesting(): boolean;
  85766. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85767. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85768. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85769. getAnimatables(): BABYLON.IAnimatable[];
  85770. getActiveTextures(): BABYLON.BaseTexture[];
  85771. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85772. dispose(forceDisposeEffect?: boolean): void;
  85773. clone(name: string): NormalMaterial;
  85774. serialize(): any;
  85775. getClassName(): string;
  85776. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85777. }
  85778. }
  85779. declare module BABYLON {
  85780. /** @hidden */
  85781. export var shadowOnlyPixelShader: {
  85782. name: string;
  85783. shader: string;
  85784. };
  85785. }
  85786. declare module BABYLON {
  85787. /** @hidden */
  85788. export var shadowOnlyVertexShader: {
  85789. name: string;
  85790. shader: string;
  85791. };
  85792. }
  85793. declare module BABYLON {
  85794. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85795. private _activeLight;
  85796. private _needAlphaBlending;
  85797. constructor(name: string, scene: BABYLON.Scene);
  85798. shadowColor: BABYLON.Color3;
  85799. needAlphaBlending(): boolean;
  85800. needAlphaTesting(): boolean;
  85801. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85802. get activeLight(): BABYLON.IShadowLight;
  85803. set activeLight(light: BABYLON.IShadowLight);
  85804. private _getFirstShadowLightForMesh;
  85805. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85806. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85807. clone(name: string): ShadowOnlyMaterial;
  85808. serialize(): any;
  85809. getClassName(): string;
  85810. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85811. }
  85812. }
  85813. declare module BABYLON {
  85814. /** @hidden */
  85815. export var simplePixelShader: {
  85816. name: string;
  85817. shader: string;
  85818. };
  85819. }
  85820. declare module BABYLON {
  85821. /** @hidden */
  85822. export var simpleVertexShader: {
  85823. name: string;
  85824. shader: string;
  85825. };
  85826. }
  85827. declare module BABYLON {
  85828. export class SimpleMaterial extends BABYLON.PushMaterial {
  85829. private _diffuseTexture;
  85830. diffuseTexture: BABYLON.BaseTexture;
  85831. diffuseColor: BABYLON.Color3;
  85832. private _disableLighting;
  85833. disableLighting: boolean;
  85834. private _maxSimultaneousLights;
  85835. maxSimultaneousLights: number;
  85836. constructor(name: string, scene: BABYLON.Scene);
  85837. needAlphaBlending(): boolean;
  85838. needAlphaTesting(): boolean;
  85839. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85840. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85841. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85842. getAnimatables(): BABYLON.IAnimatable[];
  85843. getActiveTextures(): BABYLON.BaseTexture[];
  85844. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85845. dispose(forceDisposeEffect?: boolean): void;
  85846. clone(name: string): SimpleMaterial;
  85847. serialize(): any;
  85848. getClassName(): string;
  85849. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85850. }
  85851. }
  85852. declare module BABYLON {
  85853. /** @hidden */
  85854. export var skyPixelShader: {
  85855. name: string;
  85856. shader: string;
  85857. };
  85858. }
  85859. declare module BABYLON {
  85860. /** @hidden */
  85861. export var skyVertexShader: {
  85862. name: string;
  85863. shader: string;
  85864. };
  85865. }
  85866. declare module BABYLON {
  85867. /**
  85868. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85869. * @see https://doc.babylonjs.com/extensions/sky
  85870. */
  85871. export class SkyMaterial extends BABYLON.PushMaterial {
  85872. /**
  85873. * Defines the overall luminance of sky in interval ]0, 1[.
  85874. */
  85875. luminance: number;
  85876. /**
  85877. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85878. */
  85879. turbidity: number;
  85880. /**
  85881. * Defines the sky appearance (light intensity).
  85882. */
  85883. rayleigh: number;
  85884. /**
  85885. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85886. */
  85887. mieCoefficient: number;
  85888. /**
  85889. * Defines the amount of haze particles following the Mie scattering theory.
  85890. */
  85891. mieDirectionalG: number;
  85892. /**
  85893. * Defines the distance of the sun according to the active scene camera.
  85894. */
  85895. distance: number;
  85896. /**
  85897. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85898. * "inclined".
  85899. */
  85900. inclination: number;
  85901. /**
  85902. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85903. * an object direction and a reference direction.
  85904. */
  85905. azimuth: number;
  85906. /**
  85907. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85908. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85909. */
  85910. sunPosition: BABYLON.Vector3;
  85911. /**
  85912. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85913. * .sunPosition property.
  85914. */
  85915. useSunPosition: boolean;
  85916. /**
  85917. * Defines an offset vector used to get a horizon offset.
  85918. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85919. */
  85920. cameraOffset: BABYLON.Vector3;
  85921. private _cameraPosition;
  85922. /**
  85923. * Instantiates a new sky material.
  85924. * This material allows to create dynamic and texture free
  85925. * effects for skyboxes by taking care of the atmosphere state.
  85926. * @see https://doc.babylonjs.com/extensions/sky
  85927. * @param name Define the name of the material in the scene
  85928. * @param scene Define the scene the material belong to
  85929. */
  85930. constructor(name: string, scene: BABYLON.Scene);
  85931. /**
  85932. * Specifies if the material will require alpha blending
  85933. * @returns a boolean specifying if alpha blending is needed
  85934. */
  85935. needAlphaBlending(): boolean;
  85936. /**
  85937. * Specifies if this material should be rendered in alpha test mode
  85938. * @returns false as the sky material doesn't need alpha testing.
  85939. */
  85940. needAlphaTesting(): boolean;
  85941. /**
  85942. * Get the texture used for alpha test purpose.
  85943. * @returns null as the sky material has no texture.
  85944. */
  85945. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85946. /**
  85947. * Get if the submesh is ready to be used and all its information available.
  85948. * Child classes can use it to update shaders
  85949. * @param mesh defines the mesh to check
  85950. * @param subMesh defines which submesh to check
  85951. * @param useInstances specifies that instances should be used
  85952. * @returns a boolean indicating that the submesh is ready or not
  85953. */
  85954. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85955. /**
  85956. * Binds the submesh to this material by preparing the effect and shader to draw
  85957. * @param world defines the world transformation matrix
  85958. * @param mesh defines the mesh containing the submesh
  85959. * @param subMesh defines the submesh to bind the material to
  85960. */
  85961. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85962. /**
  85963. * Get the list of animatables in the material.
  85964. * @returns the list of animatables object used in the material
  85965. */
  85966. getAnimatables(): BABYLON.IAnimatable[];
  85967. /**
  85968. * Disposes the material
  85969. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85970. */
  85971. dispose(forceDisposeEffect?: boolean): void;
  85972. /**
  85973. * Makes a duplicate of the material, and gives it a new name
  85974. * @param name defines the new name for the duplicated material
  85975. * @returns the cloned material
  85976. */
  85977. clone(name: string): SkyMaterial;
  85978. /**
  85979. * Serializes this material in a JSON representation
  85980. * @returns the serialized material object
  85981. */
  85982. serialize(): any;
  85983. /**
  85984. * Gets the current class name of the material e.g. "SkyMaterial"
  85985. * Mainly use in serialization.
  85986. * @returns the class name
  85987. */
  85988. getClassName(): string;
  85989. /**
  85990. * Creates a sky material from parsed material data
  85991. * @param source defines the JSON representation of the material
  85992. * @param scene defines the hosting scene
  85993. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85994. * @returns a new sky material
  85995. */
  85996. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85997. }
  85998. }
  85999. declare module BABYLON {
  86000. /** @hidden */
  86001. export var terrainPixelShader: {
  86002. name: string;
  86003. shader: string;
  86004. };
  86005. }
  86006. declare module BABYLON {
  86007. /** @hidden */
  86008. export var terrainVertexShader: {
  86009. name: string;
  86010. shader: string;
  86011. };
  86012. }
  86013. declare module BABYLON {
  86014. export class TerrainMaterial extends BABYLON.PushMaterial {
  86015. private _mixTexture;
  86016. mixTexture: BABYLON.BaseTexture;
  86017. private _diffuseTexture1;
  86018. diffuseTexture1: BABYLON.Texture;
  86019. private _diffuseTexture2;
  86020. diffuseTexture2: BABYLON.Texture;
  86021. private _diffuseTexture3;
  86022. diffuseTexture3: BABYLON.Texture;
  86023. private _bumpTexture1;
  86024. bumpTexture1: BABYLON.Texture;
  86025. private _bumpTexture2;
  86026. bumpTexture2: BABYLON.Texture;
  86027. private _bumpTexture3;
  86028. bumpTexture3: BABYLON.Texture;
  86029. diffuseColor: BABYLON.Color3;
  86030. specularColor: BABYLON.Color3;
  86031. specularPower: number;
  86032. private _disableLighting;
  86033. disableLighting: boolean;
  86034. private _maxSimultaneousLights;
  86035. maxSimultaneousLights: number;
  86036. constructor(name: string, scene: BABYLON.Scene);
  86037. needAlphaBlending(): boolean;
  86038. needAlphaTesting(): boolean;
  86039. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86040. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86041. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86042. getAnimatables(): BABYLON.IAnimatable[];
  86043. getActiveTextures(): BABYLON.BaseTexture[];
  86044. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86045. dispose(forceDisposeEffect?: boolean): void;
  86046. clone(name: string): TerrainMaterial;
  86047. serialize(): any;
  86048. getClassName(): string;
  86049. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86050. }
  86051. }
  86052. declare module BABYLON {
  86053. /** @hidden */
  86054. export var triplanarPixelShader: {
  86055. name: string;
  86056. shader: string;
  86057. };
  86058. }
  86059. declare module BABYLON {
  86060. /** @hidden */
  86061. export var triplanarVertexShader: {
  86062. name: string;
  86063. shader: string;
  86064. };
  86065. }
  86066. declare module BABYLON {
  86067. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86068. mixTexture: BABYLON.BaseTexture;
  86069. private _diffuseTextureX;
  86070. diffuseTextureX: BABYLON.BaseTexture;
  86071. private _diffuseTextureY;
  86072. diffuseTextureY: BABYLON.BaseTexture;
  86073. private _diffuseTextureZ;
  86074. diffuseTextureZ: BABYLON.BaseTexture;
  86075. private _normalTextureX;
  86076. normalTextureX: BABYLON.BaseTexture;
  86077. private _normalTextureY;
  86078. normalTextureY: BABYLON.BaseTexture;
  86079. private _normalTextureZ;
  86080. normalTextureZ: BABYLON.BaseTexture;
  86081. tileSize: number;
  86082. diffuseColor: BABYLON.Color3;
  86083. specularColor: BABYLON.Color3;
  86084. specularPower: number;
  86085. private _disableLighting;
  86086. disableLighting: boolean;
  86087. private _maxSimultaneousLights;
  86088. maxSimultaneousLights: number;
  86089. constructor(name: string, scene: BABYLON.Scene);
  86090. needAlphaBlending(): boolean;
  86091. needAlphaTesting(): boolean;
  86092. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86093. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86094. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86095. getAnimatables(): BABYLON.IAnimatable[];
  86096. getActiveTextures(): BABYLON.BaseTexture[];
  86097. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86098. dispose(forceDisposeEffect?: boolean): void;
  86099. clone(name: string): TriPlanarMaterial;
  86100. serialize(): any;
  86101. getClassName(): string;
  86102. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86103. }
  86104. }
  86105. declare module BABYLON {
  86106. /** @hidden */
  86107. export var waterPixelShader: {
  86108. name: string;
  86109. shader: string;
  86110. };
  86111. }
  86112. declare module BABYLON {
  86113. /** @hidden */
  86114. export var waterVertexShader: {
  86115. name: string;
  86116. shader: string;
  86117. };
  86118. }
  86119. declare module BABYLON {
  86120. export class WaterMaterial extends BABYLON.PushMaterial {
  86121. renderTargetSize: BABYLON.Vector2;
  86122. private _bumpTexture;
  86123. bumpTexture: BABYLON.BaseTexture;
  86124. diffuseColor: BABYLON.Color3;
  86125. specularColor: BABYLON.Color3;
  86126. specularPower: number;
  86127. private _disableLighting;
  86128. disableLighting: boolean;
  86129. private _maxSimultaneousLights;
  86130. maxSimultaneousLights: number;
  86131. /**
  86132. * @param {number}: Represents the wind force
  86133. */
  86134. windForce: number;
  86135. /**
  86136. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86137. */
  86138. windDirection: BABYLON.Vector2;
  86139. /**
  86140. * @param {number}: Wave height, represents the height of the waves
  86141. */
  86142. waveHeight: number;
  86143. /**
  86144. * @param {number}: Bump height, represents the bump height related to the bump map
  86145. */
  86146. bumpHeight: number;
  86147. /**
  86148. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86149. */
  86150. private _bumpSuperimpose;
  86151. bumpSuperimpose: boolean;
  86152. /**
  86153. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86154. */
  86155. private _fresnelSeparate;
  86156. fresnelSeparate: boolean;
  86157. /**
  86158. * @param {boolean}: bump Waves modify the reflection.
  86159. */
  86160. private _bumpAffectsReflection;
  86161. bumpAffectsReflection: boolean;
  86162. /**
  86163. * @param {number}: The water color blended with the refraction (near)
  86164. */
  86165. waterColor: BABYLON.Color3;
  86166. /**
  86167. * @param {number}: The blend factor related to the water color
  86168. */
  86169. colorBlendFactor: number;
  86170. /**
  86171. * @param {number}: The water color blended with the reflection (far)
  86172. */
  86173. waterColor2: BABYLON.Color3;
  86174. /**
  86175. * @param {number}: The blend factor related to the water color (reflection, far)
  86176. */
  86177. colorBlendFactor2: number;
  86178. /**
  86179. * @param {number}: Represents the maximum length of a wave
  86180. */
  86181. waveLength: number;
  86182. /**
  86183. * @param {number}: Defines the waves speed
  86184. */
  86185. waveSpeed: number;
  86186. /**
  86187. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86188. * will avoid calculating useless pixels in the pixel shader of the water material.
  86189. */
  86190. disableClipPlane: boolean;
  86191. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86192. private _mesh;
  86193. private _refractionRTT;
  86194. private _reflectionRTT;
  86195. private _reflectionTransform;
  86196. private _lastTime;
  86197. private _lastDeltaTime;
  86198. private _useLogarithmicDepth;
  86199. private _waitingRenderList;
  86200. private _imageProcessingConfiguration;
  86201. private _imageProcessingObserver;
  86202. /**
  86203. * Gets a boolean indicating that current material needs to register RTT
  86204. */
  86205. get hasRenderTargetTextures(): boolean;
  86206. /**
  86207. * Constructor
  86208. */
  86209. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86210. get useLogarithmicDepth(): boolean;
  86211. set useLogarithmicDepth(value: boolean);
  86212. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86213. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86214. addToRenderList(node: any): void;
  86215. enableRenderTargets(enable: boolean): void;
  86216. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86217. get renderTargetsEnabled(): boolean;
  86218. needAlphaBlending(): boolean;
  86219. needAlphaTesting(): boolean;
  86220. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86221. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86222. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86223. private _createRenderTargets;
  86224. getAnimatables(): BABYLON.IAnimatable[];
  86225. getActiveTextures(): BABYLON.BaseTexture[];
  86226. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86227. dispose(forceDisposeEffect?: boolean): void;
  86228. clone(name: string): WaterMaterial;
  86229. serialize(): any;
  86230. getClassName(): string;
  86231. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86232. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86233. }
  86234. }
  86235. declare module BABYLON {
  86236. /** @hidden */
  86237. export var asciiartPixelShader: {
  86238. name: string;
  86239. shader: string;
  86240. };
  86241. }
  86242. declare module BABYLON {
  86243. /**
  86244. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86245. *
  86246. * It basically takes care rendering the font front the given font size to a texture.
  86247. * This is used later on in the postprocess.
  86248. */
  86249. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86250. private _font;
  86251. private _text;
  86252. private _charSize;
  86253. /**
  86254. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86255. */
  86256. get charSize(): number;
  86257. /**
  86258. * Create a new instance of the Ascii Art FontTexture class
  86259. * @param name the name of the texture
  86260. * @param font the font to use, use the W3C CSS notation
  86261. * @param text the caracter set to use in the rendering.
  86262. * @param scene the scene that owns the texture
  86263. */
  86264. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86265. /**
  86266. * Gets the max char width of a font.
  86267. * @param font the font to use, use the W3C CSS notation
  86268. * @return the max char width
  86269. */
  86270. private getFontWidth;
  86271. /**
  86272. * Gets the max char height of a font.
  86273. * @param font the font to use, use the W3C CSS notation
  86274. * @return the max char height
  86275. */
  86276. private getFontHeight;
  86277. /**
  86278. * Clones the current AsciiArtTexture.
  86279. * @return the clone of the texture.
  86280. */
  86281. clone(): AsciiArtFontTexture;
  86282. /**
  86283. * Parses a json object representing the texture and returns an instance of it.
  86284. * @param source the source JSON representation
  86285. * @param scene the scene to create the texture for
  86286. * @return the parsed texture
  86287. */
  86288. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86289. }
  86290. /**
  86291. * Option available in the Ascii Art Post Process.
  86292. */
  86293. export interface IAsciiArtPostProcessOptions {
  86294. /**
  86295. * The font to use following the w3c font definition.
  86296. */
  86297. font?: string;
  86298. /**
  86299. * The character set to use in the postprocess.
  86300. */
  86301. characterSet?: string;
  86302. /**
  86303. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86304. * This number is defined between 0 and 1;
  86305. */
  86306. mixToTile?: number;
  86307. /**
  86308. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86309. * This number is defined between 0 and 1;
  86310. */
  86311. mixToNormal?: number;
  86312. }
  86313. /**
  86314. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86315. *
  86316. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86317. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86318. */
  86319. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86320. /**
  86321. * The font texture used to render the char in the post process.
  86322. */
  86323. private _asciiArtFontTexture;
  86324. /**
  86325. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86326. * This number is defined between 0 and 1;
  86327. */
  86328. mixToTile: number;
  86329. /**
  86330. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86331. * This number is defined between 0 and 1;
  86332. */
  86333. mixToNormal: number;
  86334. /**
  86335. * Instantiates a new Ascii Art Post Process.
  86336. * @param name the name to give to the postprocess
  86337. * @camera the camera to apply the post process to.
  86338. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86339. */
  86340. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86341. }
  86342. }
  86343. declare module BABYLON {
  86344. /** @hidden */
  86345. export var digitalrainPixelShader: {
  86346. name: string;
  86347. shader: string;
  86348. };
  86349. }
  86350. declare module BABYLON {
  86351. /**
  86352. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86353. *
  86354. * It basically takes care rendering the font front the given font size to a texture.
  86355. * This is used later on in the postprocess.
  86356. */
  86357. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86358. private _font;
  86359. private _text;
  86360. private _charSize;
  86361. /**
  86362. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86363. */
  86364. get charSize(): number;
  86365. /**
  86366. * Create a new instance of the Digital Rain FontTexture class
  86367. * @param name the name of the texture
  86368. * @param font the font to use, use the W3C CSS notation
  86369. * @param text the caracter set to use in the rendering.
  86370. * @param scene the scene that owns the texture
  86371. */
  86372. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86373. /**
  86374. * Gets the max char width of a font.
  86375. * @param font the font to use, use the W3C CSS notation
  86376. * @return the max char width
  86377. */
  86378. private getFontWidth;
  86379. /**
  86380. * Gets the max char height of a font.
  86381. * @param font the font to use, use the W3C CSS notation
  86382. * @return the max char height
  86383. */
  86384. private getFontHeight;
  86385. /**
  86386. * Clones the current DigitalRainFontTexture.
  86387. * @return the clone of the texture.
  86388. */
  86389. clone(): DigitalRainFontTexture;
  86390. /**
  86391. * Parses a json object representing the texture and returns an instance of it.
  86392. * @param source the source JSON representation
  86393. * @param scene the scene to create the texture for
  86394. * @return the parsed texture
  86395. */
  86396. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86397. }
  86398. /**
  86399. * Option available in the Digital Rain Post Process.
  86400. */
  86401. export interface IDigitalRainPostProcessOptions {
  86402. /**
  86403. * The font to use following the w3c font definition.
  86404. */
  86405. font?: string;
  86406. /**
  86407. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86408. * This number is defined between 0 and 1;
  86409. */
  86410. mixToTile?: number;
  86411. /**
  86412. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86413. * This number is defined between 0 and 1;
  86414. */
  86415. mixToNormal?: number;
  86416. }
  86417. /**
  86418. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86419. *
  86420. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86421. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86422. */
  86423. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86424. /**
  86425. * The font texture used to render the char in the post process.
  86426. */
  86427. private _digitalRainFontTexture;
  86428. /**
  86429. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86430. * This number is defined between 0 and 1;
  86431. */
  86432. mixToTile: number;
  86433. /**
  86434. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86435. * This number is defined between 0 and 1;
  86436. */
  86437. mixToNormal: number;
  86438. /**
  86439. * Instantiates a new Digital Rain Post Process.
  86440. * @param name the name to give to the postprocess
  86441. * @camera the camera to apply the post process to.
  86442. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86443. */
  86444. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86445. }
  86446. }
  86447. declare module BABYLON {
  86448. /** @hidden */
  86449. export var brickProceduralTexturePixelShader: {
  86450. name: string;
  86451. shader: string;
  86452. };
  86453. }
  86454. declare module BABYLON {
  86455. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86456. private _numberOfBricksHeight;
  86457. private _numberOfBricksWidth;
  86458. private _jointColor;
  86459. private _brickColor;
  86460. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86461. updateShaderUniforms(): void;
  86462. get numberOfBricksHeight(): number;
  86463. set numberOfBricksHeight(value: number);
  86464. get numberOfBricksWidth(): number;
  86465. set numberOfBricksWidth(value: number);
  86466. get jointColor(): BABYLON.Color3;
  86467. set jointColor(value: BABYLON.Color3);
  86468. get brickColor(): BABYLON.Color3;
  86469. set brickColor(value: BABYLON.Color3);
  86470. /**
  86471. * Serializes this brick procedural texture
  86472. * @returns a serialized brick procedural texture object
  86473. */
  86474. serialize(): any;
  86475. /**
  86476. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86477. * @param parsedTexture defines parsed texture data
  86478. * @param scene defines the current scene
  86479. * @param rootUrl defines the root URL containing brick procedural texture information
  86480. * @returns a parsed Brick Procedural BABYLON.Texture
  86481. */
  86482. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86483. }
  86484. }
  86485. declare module BABYLON {
  86486. /** @hidden */
  86487. export var cloudProceduralTexturePixelShader: {
  86488. name: string;
  86489. shader: string;
  86490. };
  86491. }
  86492. declare module BABYLON {
  86493. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86494. private _skyColor;
  86495. private _cloudColor;
  86496. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86497. updateShaderUniforms(): void;
  86498. get skyColor(): BABYLON.Color4;
  86499. set skyColor(value: BABYLON.Color4);
  86500. get cloudColor(): BABYLON.Color4;
  86501. set cloudColor(value: BABYLON.Color4);
  86502. /**
  86503. * Serializes this cloud procedural texture
  86504. * @returns a serialized cloud procedural texture object
  86505. */
  86506. serialize(): any;
  86507. /**
  86508. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86509. * @param parsedTexture defines parsed texture data
  86510. * @param scene defines the current scene
  86511. * @param rootUrl defines the root URL containing cloud procedural texture information
  86512. * @returns a parsed Cloud Procedural BABYLON.Texture
  86513. */
  86514. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86515. }
  86516. }
  86517. declare module BABYLON {
  86518. /** @hidden */
  86519. export var fireProceduralTexturePixelShader: {
  86520. name: string;
  86521. shader: string;
  86522. };
  86523. }
  86524. declare module BABYLON {
  86525. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86526. private _time;
  86527. private _speed;
  86528. private _autoGenerateTime;
  86529. private _fireColors;
  86530. private _alphaThreshold;
  86531. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86532. updateShaderUniforms(): void;
  86533. render(useCameraPostProcess?: boolean): void;
  86534. static get PurpleFireColors(): BABYLON.Color3[];
  86535. static get GreenFireColors(): BABYLON.Color3[];
  86536. static get RedFireColors(): BABYLON.Color3[];
  86537. static get BlueFireColors(): BABYLON.Color3[];
  86538. get autoGenerateTime(): boolean;
  86539. set autoGenerateTime(value: boolean);
  86540. get fireColors(): BABYLON.Color3[];
  86541. set fireColors(value: BABYLON.Color3[]);
  86542. get time(): number;
  86543. set time(value: number);
  86544. get speed(): BABYLON.Vector2;
  86545. set speed(value: BABYLON.Vector2);
  86546. get alphaThreshold(): number;
  86547. set alphaThreshold(value: number);
  86548. /**
  86549. * Serializes this fire procedural texture
  86550. * @returns a serialized fire procedural texture object
  86551. */
  86552. serialize(): any;
  86553. /**
  86554. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86555. * @param parsedTexture defines parsed texture data
  86556. * @param scene defines the current scene
  86557. * @param rootUrl defines the root URL containing fire procedural texture information
  86558. * @returns a parsed Fire Procedural BABYLON.Texture
  86559. */
  86560. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86561. }
  86562. }
  86563. declare module BABYLON {
  86564. /** @hidden */
  86565. export var grassProceduralTexturePixelShader: {
  86566. name: string;
  86567. shader: string;
  86568. };
  86569. }
  86570. declare module BABYLON {
  86571. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86572. private _grassColors;
  86573. private _groundColor;
  86574. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86575. updateShaderUniforms(): void;
  86576. get grassColors(): BABYLON.Color3[];
  86577. set grassColors(value: BABYLON.Color3[]);
  86578. get groundColor(): BABYLON.Color3;
  86579. set groundColor(value: BABYLON.Color3);
  86580. /**
  86581. * Serializes this grass procedural texture
  86582. * @returns a serialized grass procedural texture object
  86583. */
  86584. serialize(): any;
  86585. /**
  86586. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86587. * @param parsedTexture defines parsed texture data
  86588. * @param scene defines the current scene
  86589. * @param rootUrl defines the root URL containing grass procedural texture information
  86590. * @returns a parsed Grass Procedural BABYLON.Texture
  86591. */
  86592. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86593. }
  86594. }
  86595. declare module BABYLON {
  86596. /** @hidden */
  86597. export var marbleProceduralTexturePixelShader: {
  86598. name: string;
  86599. shader: string;
  86600. };
  86601. }
  86602. declare module BABYLON {
  86603. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86604. private _numberOfTilesHeight;
  86605. private _numberOfTilesWidth;
  86606. private _amplitude;
  86607. private _jointColor;
  86608. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86609. updateShaderUniforms(): void;
  86610. get numberOfTilesHeight(): number;
  86611. set numberOfTilesHeight(value: number);
  86612. get amplitude(): number;
  86613. set amplitude(value: number);
  86614. get numberOfTilesWidth(): number;
  86615. set numberOfTilesWidth(value: number);
  86616. get jointColor(): BABYLON.Color3;
  86617. set jointColor(value: BABYLON.Color3);
  86618. /**
  86619. * Serializes this marble procedural texture
  86620. * @returns a serialized marble procedural texture object
  86621. */
  86622. serialize(): any;
  86623. /**
  86624. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86625. * @param parsedTexture defines parsed texture data
  86626. * @param scene defines the current scene
  86627. * @param rootUrl defines the root URL containing marble procedural texture information
  86628. * @returns a parsed Marble Procedural BABYLON.Texture
  86629. */
  86630. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86631. }
  86632. }
  86633. declare module BABYLON {
  86634. /** @hidden */
  86635. export var normalMapProceduralTexturePixelShader: {
  86636. name: string;
  86637. shader: string;
  86638. };
  86639. }
  86640. declare module BABYLON {
  86641. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86642. private _baseTexture;
  86643. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86644. updateShaderUniforms(): void;
  86645. render(useCameraPostProcess?: boolean): void;
  86646. resize(size: any, generateMipMaps: any): void;
  86647. get baseTexture(): BABYLON.Texture;
  86648. set baseTexture(texture: BABYLON.Texture);
  86649. /**
  86650. * Serializes this normal map procedural texture
  86651. * @returns a serialized normal map procedural texture object
  86652. */
  86653. serialize(): any;
  86654. /**
  86655. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86656. * @param parsedTexture defines parsed texture data
  86657. * @param scene defines the current scene
  86658. * @param rootUrl defines the root URL containing normal map procedural texture information
  86659. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86660. */
  86661. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86662. }
  86663. }
  86664. declare module BABYLON {
  86665. /** @hidden */
  86666. export var perlinNoiseProceduralTexturePixelShader: {
  86667. name: string;
  86668. shader: string;
  86669. };
  86670. }
  86671. declare module BABYLON {
  86672. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86673. time: number;
  86674. timeScale: number;
  86675. translationSpeed: number;
  86676. private _currentTranslation;
  86677. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86678. updateShaderUniforms(): void;
  86679. render(useCameraPostProcess?: boolean): void;
  86680. resize(size: any, generateMipMaps: any): void;
  86681. /**
  86682. * Serializes this perlin noise procedural texture
  86683. * @returns a serialized perlin noise procedural texture object
  86684. */
  86685. serialize(): any;
  86686. /**
  86687. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86688. * @param parsedTexture defines parsed texture data
  86689. * @param scene defines the current scene
  86690. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86691. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86692. */
  86693. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86694. }
  86695. }
  86696. declare module BABYLON {
  86697. /** @hidden */
  86698. export var roadProceduralTexturePixelShader: {
  86699. name: string;
  86700. shader: string;
  86701. };
  86702. }
  86703. declare module BABYLON {
  86704. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86705. private _roadColor;
  86706. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86707. updateShaderUniforms(): void;
  86708. get roadColor(): BABYLON.Color3;
  86709. set roadColor(value: BABYLON.Color3);
  86710. /**
  86711. * Serializes this road procedural texture
  86712. * @returns a serialized road procedural texture object
  86713. */
  86714. serialize(): any;
  86715. /**
  86716. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86717. * @param parsedTexture defines parsed texture data
  86718. * @param scene defines the current scene
  86719. * @param rootUrl defines the root URL containing road procedural texture information
  86720. * @returns a parsed Road Procedural BABYLON.Texture
  86721. */
  86722. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86723. }
  86724. }
  86725. declare module BABYLON {
  86726. /** @hidden */
  86727. export var starfieldProceduralTexturePixelShader: {
  86728. name: string;
  86729. shader: string;
  86730. };
  86731. }
  86732. declare module BABYLON {
  86733. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86734. private _time;
  86735. private _alpha;
  86736. private _beta;
  86737. private _zoom;
  86738. private _formuparam;
  86739. private _stepsize;
  86740. private _tile;
  86741. private _brightness;
  86742. private _darkmatter;
  86743. private _distfading;
  86744. private _saturation;
  86745. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86746. updateShaderUniforms(): void;
  86747. get time(): number;
  86748. set time(value: number);
  86749. get alpha(): number;
  86750. set alpha(value: number);
  86751. get beta(): number;
  86752. set beta(value: number);
  86753. get formuparam(): number;
  86754. set formuparam(value: number);
  86755. get stepsize(): number;
  86756. set stepsize(value: number);
  86757. get zoom(): number;
  86758. set zoom(value: number);
  86759. get tile(): number;
  86760. set tile(value: number);
  86761. get brightness(): number;
  86762. set brightness(value: number);
  86763. get darkmatter(): number;
  86764. set darkmatter(value: number);
  86765. get distfading(): number;
  86766. set distfading(value: number);
  86767. get saturation(): number;
  86768. set saturation(value: number);
  86769. /**
  86770. * Serializes this starfield procedural texture
  86771. * @returns a serialized starfield procedural texture object
  86772. */
  86773. serialize(): any;
  86774. /**
  86775. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86776. * @param parsedTexture defines parsed texture data
  86777. * @param scene defines the current scene
  86778. * @param rootUrl defines the root URL containing startfield procedural texture information
  86779. * @returns a parsed Starfield Procedural BABYLON.Texture
  86780. */
  86781. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86782. }
  86783. }
  86784. declare module BABYLON {
  86785. /** @hidden */
  86786. export var woodProceduralTexturePixelShader: {
  86787. name: string;
  86788. shader: string;
  86789. };
  86790. }
  86791. declare module BABYLON {
  86792. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86793. private _ampScale;
  86794. private _woodColor;
  86795. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86796. updateShaderUniforms(): void;
  86797. get ampScale(): number;
  86798. set ampScale(value: number);
  86799. get woodColor(): BABYLON.Color3;
  86800. set woodColor(value: BABYLON.Color3);
  86801. /**
  86802. * Serializes this wood procedural texture
  86803. * @returns a serialized wood procedural texture object
  86804. */
  86805. serialize(): any;
  86806. /**
  86807. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86808. * @param parsedTexture defines parsed texture data
  86809. * @param scene defines the current scene
  86810. * @param rootUrl defines the root URL containing wood procedural texture information
  86811. * @returns a parsed Wood Procedural BABYLON.Texture
  86812. */
  86813. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86814. }
  86815. }